jqxhr

Calling $http.get() multiple times always returns cached result

ⅰ亾dé卋堺 提交于 2019-12-12 04:07:32
问题 I have an angular controller that makes repeated gets via the $http object, like this: $scope.refresh = function() { let url = 'api/get-status'; $http.get( url ).then( function( response ) { console.log( response.data ); }); }; $scope.intervalFunction = function() { $timeout( function() { $scope.refresh(); $scope.intervalFunction(); }, 2000 ) // msec }; $scope.refresh(); $scope.intervalFunction(); The fetches appear to happen. When I do this in chrome I see the results coming back as expected

Association between Backbone Collection and XHR object created when fetching

梦想的初衷 提交于 2019-12-11 08:22:15
问题 Is there an existing association between a Backbone Collection and the XHR object created when you execute a .fetch() on it? I would like to do something like this: collection = new Backbone.Collection; xhrObj = collection.fetch(); xhrObj.parent == collection; //true The larger goal is for me to check to see if there are any pending .fetch() 's for a specific collection. If there is another way to do this in Backbone, please let me know. I figured I would just store XHR objects and check if

jQuery.ajax with POST or PUT has no response headers for IE8 and IE9

二次信任 提交于 2019-12-11 07:48:10
问题 I've noticed that with IE8 and IE9, if I call my RESTful API using jQuery.ajax() with POST and PUT verbs, then I don't get back any response headers in jqXHR. However, GET requests work as expected. This behavior is different from all other browsers. I've verified that Chrome, FF, Opera, and Safari all return the full set of expected headers in the response for POST and PUT requests. Only IE8 and IE9 seem to be throwing the headers on the floor. (One thing I haven't checked is what happens

Problems Reading the HTTP Status/Error Code from jQuery AJAX

对着背影说爱祢 提交于 2019-12-11 06:25:24
问题 I'm trying to appropriately handle a HTTP status error (404, 501, etc) that might be returned by any AJAX call in jQuery (I'm using version 1.6.4) however for the life of me I can't get out the appropriate response code (all values are '0' or 'error' and nothing more specific). UPDATE: created a JSFIDDLE here UPDATE: added statusCode: { *** } as per 3nigma's suggestion BUT which does not fire <!DOCTYPE html><html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs

Delay JQuery Ajax (jqXHR) Request with done/fail/complete callbacks

北战南征 提交于 2019-12-11 05:38:00
问题 When I use success callback this solution works fine, but when I use .done() this fail, how I can retry send enqueued ajax request with original .done() .fail() and complete() registered callbacks? var requestQueue = []; $.ajaxSetup({ cache: false, beforeSend: function (jqXHR, options) { if(true){ //any condition 'true' just demonstrate requestQueue.push({request:jqXHR,options:options}); //simulate process this queue later for resend the request window.setTimeout(function(){ //this will work

Get more information from a failed JQuery jqXHR request

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 23:15:37
问题 I'm using JQuery's $.when and $.get to fetch some data and do something with it. When there is an error fetching it or doing something with it, I want to handle that error, and handle it differently depending on which data I was fetching/at which path I was fetching it. Unfortunately, the information passed to $.when().fail(...) is scant, and doesn't include that information. How might I bubble up that information from the deferrable in a non-hacky[1] way? $.when(get(path1), get(path2) .done

How to get jQuery.ajax response status?

丶灬走出姿态 提交于 2019-12-10 02:38:35
问题 Is there any way to know if the jqXHR object returned was redirected from another request? For example, having the following code: jQuery.ajax({ type: 'POST', url: 'http://example.com/page.html', complete: function(response, status) { console.log(response.statusCode); // do something } }); If the ajax url is redirected with a 301 or 302 status code, the response will be the result of the redirected page and will return a 200 (OK) status code. I think this is a jQuery's bug (don't really know

When a response to $.ajax is 301, can I programmatically get the new URL?

核能气质少年 提交于 2019-12-09 05:19:35
问题 Is there a way to get the URL you are ultimately redirected to when the response to an xhr request is 301? I have a site that contains numerous legacy URLs from an older version, which return 301 responses to the correct new URL. For utility purposes, I would like to be able to make a request to an old URL, and be able to retrieve the new one i.e. send request to "/oldpage.aspx?foo=someParam", get back the new url "/arbitaryNewPageName/someParam". I've been playing around with this in the

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

Deadly 提交于 2019-12-07 08:32:49
问题 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 $("[ref=B]").html(data).find( '[ref=A]' ); However, if I do so, the entire page will write on <span ref='B'> first then find the selector inside of it..... The alternative way to only find '[ref=A]' is html = $(data).filter('[ref=B]').find('[ref=A]').html() /

Reasons not to use native XMLHttpRequest - why is $.ajax mandatory?

痴心易碎 提交于 2019-12-07 01:58:54
问题 I'm writing an app that: absolutely relies on sending data to server via Javascript must not have JQuery library included in code. (I don't know if my code will be included in web pages that already have jquery lib, I do not know if there's gonna be right version, I do not know if there is gonna be JQuery conflict and so... ) I must relay on native JS functionality XMLHttpRequest(ActiveX for older IE's) methods, which is simple but than I saw warning: "Without jQuery, AJAX coding can be a bit