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.
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.
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.
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.
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.
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, // ... });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With