Ajax success function returning [object, object]

how to solve object object error in jquery
ajax error function object object
json returns object object
object object ajax request
parse object object in jquery
showing object object in jquery
get value from object object jquery
how to parse the json object in ajax success

I'm very new to AJAX calls - poked around the web for a few tutorials but still not quite getting successful at it.

The input field has an assigned ID of "idkey". The script is as follow:

$(document).on("keyup.autocomplete", "#idkey", function(){ 
    var query = "q=" + $(this).val();
        url: 'api.php',
        type: 'GET',
        data: query,
        dataType: 'json',
        success: function(data) {
            for (var i=0;i<data.length;i++) {
                content = data[i].IDKey;
                content += "<br>";
                // updateListing(data[x]);

On the server side, the api.php has an output of:


I am not sure why the alert(data) would return [object Object], [object Object], [object Object]. Any clue to why this is happening?

p/s: The php file has a header set to Content-Type: application/json.

Your json response is an array of 3 objects . That's the reason you are seeing the alert as an object..

Try alert(data[0].IDKey) .. It should give you 30000001

To see the data try console.log or place the alert inside for loop

for (var i=0;i<data.length;i++) {

$.each(data, function(i, value) {
   console.log('Value of '+ i +' is : ' + value);

Ajax call fails and returns [object Object], But now when I test my ajax call it fails and returns [object Object] and I city: city }, success: function (data) { console.log("success: " + data);  ajax is by nature asyc. The code doesn't wait for the response from your success callback, so the data isn't accessible outside of success unless passed.. You'd need to handle the data inside the success, try calling a separate method/function:

type alert(JSON.stringify(data));

AJAX & Deferreds, $.ajax() (and related convenience methods) returns a jqXHR object — a can use the .then() method of the jqXHR object to attach success and error callbacks. return Because wrapped success Then in your success function,you can iterate over each object and update the page You can just return one big JSON result.Because each of your JSON objects can be wrapped in another. The JSON you return would then be an array of objects (whatever they may be)

alert returns [object Object], [object Object], [object Object] because you have array of 3 javascript objects and objects can't be just alerted as strings, you can use console.log to see the content of the object, just use console.log instead of alert and check the console of your browser

[Solved] AJax JASON Jquery returning [Object Object], I am using ajax jason in my application developed in .net 2.0.When i migrated to .​net 4.0 the ajax function returning a jason object as [Object  alert returns [object Object], [object Object], [object Object] because you have array of 3 javascript objects and objects can't be just alerted as strings, you can use console.log to see the content of the object, just use console.log instead of alert and check the console of your browser

The alert(data) is returning three objects because that is what JSON is.. Javascript Object Notation.

It's returning an array objects, that's all its returning, and that's why it shows up the way it does.

If you want to see the results of such an array.. what each object contains, then you need to use console.log():


.ajaxSuccess(), ajaxSuccess( handler )Returns: jQuery. Description: Attach a function to be executed whenever an Ajax request completes successfully. Each time an ajaxSuccess handler is executed, it is passed the event object, the XMLHttpRequest  Let’s take a look at a specific Ajax functionality: returning an Ajax response from an asynchronous JavaScript call. First, What is Ajax? Asynchronous JavaScript and XML, or Ajax, isn’t a new technology in itself, and it’s not a programming language. The term was coined back in 2005 by Jesse James Garrett.

what Sushanth said above

    for (var i=0;i<data.length;i++) {

If you are using IE, remember to get rid of or comment out the console.log() methods. IE doesn't like them very much.

Jquery AJAX Result data retrieve back to client si, Currently, in "Result" object shows all HTML text. { return data; }, success: function (data) { var results = $.map(data, function(item){ return { value: item.value​,  I'm using ajax to get a bunch of messages. The get call works fine, but I don't know how to get the specific key values from the object in the array. I've used console.log to get the actual array which is here:

How to return data after ajax call success, Example object with ajax method var Example = (function () { // ctor function self() { } // Ajax request method self.Request = function (params)  The task I took recently was to refactor AMD modules in the project. A simple challenge is how to launch a request and return the result from an AMD module. What we expect is our modules can return…

How to Return AJAX Response from Asynchronous JavaScript Call, Learn how to return AJAX response from an asynchronous JavaScript Cascading Style Sheets, JavaScript, The Document Object Model, XML, XSLT, A callback is a function that would give you the result or response you  Ajax function to return value. JavaScript. esthera. August 30, 2014, The confirm is not called because the ajax request is not success so that it will not call the successCallBack. Please

Ajax function to return value - JavaScript, I have a function that i want to call another function to get a result from the server web 'text/html', success:function(data) { //alert('xx'); //alert(data); return(data); 

  • Thanks for the helpful answer - if now I'm wanting to output all 3 objects, how should I get around to do it?
  • Ah, nevermind. I just discovered the power of .each() :) stackoverflow.com/questions/733314/…