Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax going to [object%20Object]

Tags:

jquery

I'm just trying to do a simple request like this:

    $('.asd').change(         function () {             $.ajax({                 url: 'http://127.0.0.1/folder/index.php/controller/action/integer',                 success: function(data){}             });         }     ); 

This code tries to go to http://127.0.0.1/folder/index.php/controller/[object%20Object] instead and gets a 404. Where is it pulling the object from? I'm using a simple string.

like image 584
user781655 Avatar asked Aug 29 '11 11:08

user781655


People also ask

What is jqXHR in Ajax?

The jqXHR (jQuery XMLHttpRequest) replaces the browser native XMLHttpRequest object. jQuery wraps the browser native XMLHttpRequest object with a superset API. The jQuery XMLHttpRequest (jqXHR) object is returned by the $. ajax() function. The jqXHR object simulates native XHR functionality where possible.

How do you fix an object object in HTML?

To fix this, you can use the JSON. stringify() method to change the object into a string that can be popped up in the browser using the alert() method.

What type of object does Ajax return?

ajax() function returns the XMLHttpRequest object that it creates. Normally jQuery handles the creation of this object internally, but a custom function for manufacturing one can be specified using the xhr option.

What is object object in jQuery?

Introduction to jQuery object. The jQuery object is a collection of DOM elements and behaves like a special array. Everything in jQuery is an object. When we create a new element or select an existing element the jQuery returns those elements in a collection.


1 Answers

For me the issue was that I was using $.post instead of $.ajax.

// fails: $.post({     url: "/example/" + this.id,     // ... });  // works: $.ajax({     url: "/example/" + this.id,     // ... }); 
like image 192
sffc Avatar answered Oct 22 '22 09:10

sffc