As mentioned in the documentation:
When the handler has finished all of its tasks, it needs to die. If
you are using the WP_Ajax_Response or wp_send_json* functions, this is
automatically handled for you. If not, simply use the WordPress
wp_die()
function.wp_die(); // That's all folks!
So you either need to use:
$result['success'] = false;
$result['string'] = 'You have not uploaded project file, please upload first!';
echo json_encode( $result );
wp_die();
Or
$result['success'] = false;
$result['string'] = 'You have not uploaded project file, please upload first!';
wp_send_json( $result );
You can also send a JSON with the success
property set to false
for you like this:
$result="You have not uploaded project file, please upload first!";
wp_send_json_error( $result, 400 );
That will result in something like:
{
"success": false,
"data": "You have not uploaded project file, please upload first!"
}