I have a simple Ajax call like
$('#getOrgs').on('click', function() {
var form_data=new FormData(document.getElementsByName('f_xmlupdates')[0]);
$.ajax({
url: 'ajax/getOrgs.php',
dataType: 'json',
contentType: false,
processData: false,
data: form_data,
type: 'post',
success: function(php_script_response){
$('#atscale_org').empty();
jQuery.each( php_script_response, function( i, val ) {
$('#atscale_org').append($('<option></option>').val(val[0]).html(val[1]));
});
$('#getOrgs').css('background','dimgrey');
},
error: function ( error ) {
console.log("Something Wrong with GetOrgs..."+JSON.stringify(error));
}
});
});
Php Side - getOrgs.php
<?php
header('Content-Type: application/json; charset=utf-8');
include('../utils/utils.php');
$organization = get_orgs_from_pg( $_POST["atscale_server"] );
echo json_encode($organization,TRUE);
exit();
?>
I am using Apache WebServer 2.4.29 .This above code fills a select box. This works fine most of the day , sometimes (Once in few days) Ajax call goes into Error block instead of Success block. I see ServerState:4 error message. And I see the response from PHP has tags starting with
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
{json Response}
</body>
</html>
The issue goes away once I restart the Apache Web Server. Can someone give me any pointers , which process is adding the HTML tags ? and why Its happening suddenly?
Looks like the issue was with "htmlentities($row[2], ENT_XHTML) )" method within my php function. When I remove it i can see the error is getting resolved. Thanks all for your comments !!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.