I am using wordpress. I don't know why some blank lines will appear in the returned results. Jquery {code...} PHP {code ...}
I am using wordpress. I don't know why some blank lines will appear in the returned results.
Jquery
$.ajax({ type:'post', url:localcurrent.ajax_url, data:favorite_data, success:function(response){ alert(response); } });
PHP
Function favorite_post () {$ post_id = $ _ POST ["post_id"]; $ user_id = get_current_user_id (); $ favorite = favorite_get ($ post_id, 1 ); // determine whether the user has added this article to the favorites if (! In_array ($ user_id, $ favorite) {// This item is not added to the user's favorites. To add the favorites favorite_add ($ user_id, $ post_id); echo 'add'; exit ;} else {// The user has added this item to favorites. To remove the added item from favorites, favorite_del ($ user_id, $ post_id); echo 'delete'; exit;} echo 'error'; exit ;} add_action ('wp _ ajax_favorite_post', 'favorite _ Post ');
Reply content:
I am using wordpress. I don't know why some blank lines will appear in the returned results.
Jquery
$.ajax({ type:'post', url:localcurrent.ajax_url, data:favorite_data, success:function(response){ alert(response); } });
PHP
Function favorite_post () {$ post_id = $ _ POST ["post_id"]; $ user_id = get_current_user_id (); $ favorite = favorite_get ($ post_id, 1 ); // determine whether the user has added this article to the favorites if (! In_array ($ user_id, $ favorite) {// This item is not added to the user's favorites. To add the favorites favorite_add ($ user_id, $ post_id); echo 'add'; exit ;} else {// The user has added this item to favorites. To remove the added item from favorites, favorite_del ($ user_id, $ post_id); echo 'delete'; exit;} echo 'error'; exit ;} add_action ('wp _ ajax_favorite_post', 'favorite _ Post ');
I think there are two situations:
1. Something in the PHP template as mentioned above.
2. The returned data contains UTF-8 text in BOM format.
Is the php tag deleted at the top of the php template file? I did the same before. After checking for a long time, I found that I deleted some things at the top of the template file.
Use a browser to capture packets