I am currently writing my first WordPress plugin.
If I now make a jquery ajax call on a click and call a php function, even if in this function is only sleep 10 and wp_die(), and I try during this to load the page in the frontend, the page loads only after the 10 seconds are over.
this call blocks the whole page at that moment. Why?
Here is my js
var data = {
'action': 'my_export_retailer_import',
'csv_file_path': csv_file_path
};
$.ajax({
type: 'POST',
url: ajaxurl,
data: data,
success: function(data){
}
});
Heres the PHP Function
add_action('wp_ajax_my_export_retailer_import', 'my_export_retailer_import', 30);
function my_export_retailer_import() {
sleep(10);
wp_die(); // this is required to return a proper result
};
// ----------
Edit: I have been able to identify the problem. When starting the website, there is a session_start() in the functions.php.
If I comment this out, all is well.
Fortunately, I don't actually need the session at that moment. Just a little redo in another function :-)