Questions tagged [jqxhr]

jqXHR is a jQuery object that provides a JavaScript cross-browser-compatible superset (wrapper) object for the browser-implemented XMLHttpRequest (XHR) object.

The jQuery XMLHttpRequest object (jqXHR in short) is returned by jQuery's $.ajax() method and as of jQuery 1.5, it is a superset of the browser's native XMLHttpRequest object. Among several properties and methods, it contains responseText, responseXML, and the getResponseHeader() method.

Example:

// send an AJAX request as usual
$.ajax('data.php'))    
  .done(function() {
    // the AJAX request was successful
    console.log('$.ajax succeeded');
  })      
  .fail(function() {
    // the AJAX request was unsuccessful
    console.log('$.ajax failed');
  })  
  .always(function() {
    // from jQuery 1.6, this function will always be called
    // either the AJAX request was successful or unsuccessful
    console.log('$.ajax either succeeded or failed');
  });

Resources

Related Tags

177 questions
6
votes
1 answer

Custom ajaxTransport function without specified dataType is not firing (AT ALL!)

I have been trying to setup custom ajaxTransports for jQuery to short-circuit some workflows in certain scenarios for our product. However, I have had zero success in getting these transports to be honored (whereas I have many working custom…
James M. Greene
  • 1,251
  • 1
  • 16
  • 23
5
votes
1 answer

What are the variables [[FunctionLocation]], [[Scopes]]: in the Browser Console

When using jQuery Ajax, in the Browser console I can see the xhr object has two props / fields in some weird notation [double square brackets, don't think it means array in this case]; First, what exactly are they, and second, can I access these…
joedotnot
  • 4,810
  • 8
  • 59
  • 91
5
votes
2 answers

JQuery ajax call getting status code 0 "error"

I'm trying to call Petfinder.com to get a list of our pets. The url is http://api.petfinder.com/shelter.getPets?key=xxxxx&id=CA1469&format=json The url seems to return the JSON fine. But when I try to make the call I'm getting "error" and status…
Judith Adabie
  • 51
  • 1
  • 1
  • 2
4
votes
1 answer

What's the reason/primary benefit of jQuery 1.5's jqXHR?

I'm curious, what are the intentions of the jqXHR wrapper? Is there something about it that improves development?
Chaddeus
  • 13,134
  • 29
  • 104
  • 162
4
votes
2 answers

How to abort script loading

Is it possible to stop loading of the JS file loaded in the below way, are there any event handlers? function makeScript(url){ script = document.createElement("script"); script.src = url; //when this line is executed the script…
Mumzee
  • 719
  • 1
  • 11
  • 25
4
votes
2 answers

How to use ajax to set the src of an image?

I need to set some headers when getting an image. The img src attribute does not allow this, so I'm using an XHR request to get the image. However, when I set the src attribute on the img tag after that request completes, it looks like the request…
mehulkar
  • 4,895
  • 5
  • 35
  • 55
4
votes
2 answers

JS: how to encode an image.png into base64 code for data URI embedding?

I have several .png bitmaps of different dimensions, by example ./img/dog.png and ./img/cat.png. How to load the base64 string of my images via JS ? My expected data is omething like that (but far longer): …
Hugolpz
  • 17,296
  • 26
  • 100
  • 187
4
votes
3 answers

JQuery and XHR -- Cross-site JSON POST with CORS

I'm making a small UI to submit a JSON object to an external CastIron server (not that the server type is important to this question) using jQuery. The initial send works fine, but I'm not getting the response from the server. Here's what the…
coding_hero
  • 1,759
  • 3
  • 19
  • 34
4
votes
1 answer

Call jqXHR.abort without triggering an error?

I have a jqXHR object which I get from a backbone collection: var xhr = this.collection.fetch({ error: function() { alert("oh noes!"); } }); Sometimes I then need to call xhr.abort(). But this is also triggering the error callback. How can I…
user1031947
  • 6,294
  • 16
  • 55
  • 88
4
votes
1 answer

responseType in $.ajax

$.ajax({ type: "POST", url: "bla", xhrFields: { responseType: "document" }, data: {}, success: function(arg,arg2,request){ console.log(request.responseXML) } }) Why is it printing 'undefined'? How would I fix this?
Luaox
  • 167
  • 1
  • 3
  • 13
4
votes
2 answers

How do I filter body html the returned data from ajax?

My purpose is, I want to take specific html out from data and update that area only. How do I filter the returned data from jQuery.ajax? This link is a old post but I do have the exactly same problem. The solution giving from the link is…
Micah
  • 4,254
  • 8
  • 30
  • 38
3
votes
1 answer

Uploading large file (100mb+) crashes Chrome only

I am allowing users to upload CSV files through the website. The file is getting read using the JavaScript file API then getting sent through to the server to be saved. , upload: function (prefix, numberType, file, name) { this.attributes = {…
AnthonyG95
  • 85
  • 2
  • 9
3
votes
1 answer

jquery datatables : load real time progress bar

A normal ajax real time progress bar loads like this, $.ajax({ xhr: function() { var xhr = new window.XMLHttpRequest(); xhr.upload.addEventListener("progress", function(e) { var pro = (e.loaded /…
Ashan
  • 479
  • 7
  • 28
3
votes
1 answer

JavaScript Ajax (jQuery.post) Bizarre Error: state = "rejected"

So I've been trying to debug my jQuery.post() call, and have been getting some weird responses. I'm stuck on what to do next, if anyone had any suggestions, I'd really appreciate it.