Jump to content

Passing database query rows with ajax json


Recommended Posts



I want to get sql query rows result info through ajax and json.


Here´s jquery code:


var mod_url = baseDir + '/json_2.php';


var query = $.ajax({
  type: 'POST',
  url: mod_url,
  dataType: 'json',
  success: function(comp_arr) {
  error: function (response) {

And here´s php file code :

$qr = 'SELECT * FROM '._DB_PREFIX_.'infos_it WHERE infoit=1';
if ($results = Db::getInstance()->ExecuteS($qr))
foreach ($results as $row) {
$comp_arr[$i]["id_item"] = $row["id_id_item"];
$comp_arr[$i]["infoit"] = $row["infoit"];
$comp_arr[$i]["icon"] = $row["icon"];

Jquery Ajax Response is success but null...what I´m doing wrong?




Link to comment
Share on other sites

More information and tests..


If I execute same query and var_dump directly to database, with $cfg_server= "localhost"; $cfg_database = "xxxx"; $cfg_username = "xxxxx"; $cfg_password = "xxxxx"; instead of  Db::getInstance()->ExecuteS($qr), it works correctly and return 19 records with all its fields.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...