Click here to Skip to main content
14,643,840 members
Rate this:
Please Sign up or sign in to vote.
See more:
AJAX request not returns response in hosting server.

I have tested it in localhost it works normally but when I am testing it in hosting server it returns blank response.

I have checked values in variable using var_dump. It is having value but when I echo it using json_encode method it returns blank response.
Posted
Comments
Sradhanjali Behera 25-Nov-15 6:42am
   
Please alert your data.what is coming.
jagdish123061 25-Nov-15 6:44am
   
response is blank.

json_encode not working
Sradhanjali Behera 25-Nov-15 6:47am
   
$result['Comments'] = $comm;
echo json_encode($result);
exit;
Sradhanjali Behera 25-Nov-15 6:48am
   
echo it and console it.
jagdish123061 25-Nov-15 6:57am
   
solved it. problem in values some values are not in collation utf-8. So i had convert it using function:

function utf8ize($d) {
if (is_array($d)) {
foreach ($d as $k => $v) {
$d[$k] = utf8ize($v);
}
} else if (is_string ($d)) {
return utf8_encode($d);
}
return $d;
}


and then echo json_encode(utf8ize($result))

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

solved it. problem in values some values are not in collation utf-8. So i had convert it using function:

<pre lang="PHP">
function utf8ize($d) {
  if (is_array($d)) {
    foreach ($d as $k => $v) {
       $d[$k] = utf8ize($v);
    }
  }
  else if (is_string ($d)) {
        return utf8_encode($d);
  }
 return $d;
}



and then echo json_encode(utf8ize($result))
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100