0

enter image description here

I have the following jquery code:

                    $.ajax({
                        type: "POST",
                        url: "Ajax/getTableRecord",
                        data:{ i : id, t: 'mylist'},                        
                        dataType: 'json',
                        success: function(data){
                            alert(data);
                        }

When I activate this, the php function getTableRecord, queries a db and ends with:

echo json_encode($array);

I can see the correct returned data in my console. However the alert function just shows the contents of the screenshot. How do I display the returned key value pairs in the alert box instead?

user1592380
  • 34,265
  • 92
  • 284
  • 515

2 Answers2

3

You can do

console.log(data);

or JSON.stringify() like this

JSON.stringify(data);
Dhiraj
  • 33,140
  • 10
  • 61
  • 78
2

Use the console

console.log(data); 

instead of

alert(data);

you can check how to open the console on each browser here https://webmasters.stackexchange.com/questions/8525/how-to-open-the-javascript-console-in-different-browsers

Community
  • 1
  • 1
Juank
  • 6,096
  • 1
  • 28
  • 28