php - Jquery POST and AJAX prepend double space to returned data -
i still struggling problem after 2 weeks no sign of solution.
any data returned php using $.ajax or $.post has 2 spaces added onto returned data. have trimmed data being echoed in php confirm it's not issue server or scripts.
e.g.
echo '{"id": "'.$myid.'"}'; becomes:
' {"id": "'.$myid.'"}' when viewing returned data in inspector. causes problems js scripts because expect nothing returned when there no error. double space returned causes errors when there none, in turn stops other events firing.
i using jquery 1.8.3.
does have idea causing extremely strange , annoying issue?
i using netbeans
i recall started happening since moved app new server, don't see how have effected in way.
this may helpful,
i think there whitespace in script (may included files, not sure). can overcome clearing output buffer, before send data browser. following code demonstrate idea.
<?php ob_start(); echo ' '; // possible whitespace (may included files) ---------- ---------- if (your_check_for_ajax_request) { ob_end_clean(); $myid = 1; echo '{"id": "'.$myid.'"}'; exit; } ?>
Comments
Post a Comment