Organizational Research By

Surprising Reserch Topic

Ajax - Can't get json data

I'm quite a beginner in ajax technology. I have a php for execute a mysql_query and I would like to use the result on the client side.

My database.php:

$q=mysql_query("SELECT name FROM customers");
echo json_encode($res);

and my client.php

 id="output">this element will be accessed by jquery and this text replaced 
id="source" language="javascript" type="text/javascript"> $(function () { $.ajax({ url: 'database.php', //the script to call to get data data: "", dataType: 'json', //data format success: function(data) //on recieve of reply { var name = data[0]; $('#output').html("id: "+name); } }); });

This is from some tutorial I've found. And as I saw the database.php works. It prints right data, but in the client.php I can't get anything. What could be the problem?


So, seems like on the web server runs php 4.4.7 and looks like json_encode() function does not wokrs because of that. I' ve found a "solution". I include upgrade.php, which implemets new methods for older versions of php, as far as i understands. here is the webste of it

I can't upgrade php version so could this be a good solution? At the moment it does not works

asked Apr 24, 2015 in ajax by rajesh
0 votes

Related Hot Questions

2 Answers

0 votes
answered Apr 24, 2015 by rajesh
0 votes
answered Apr 24, 2015 by rajesh