jqxhr

Ajax jQuery multiple calls at the same time - long wait for answer and not able to cancel

大兔子大兔子 提交于 2020-01-04 15:29:43
问题 My problem is as follows: On a page, I am doing multiple (6) ajax calls (via jQuery) to fetch some data at the same time (using php wrapper to fetch the data via the calls) The requests are made at the same time and it takes them 10-20 seconds to complete If user clicks on any of the links to go somewhere else (to some other page), I can see that all the calls that didn't complete get cancelled However, the browser still waits for 20 seconds to navigate to the other page - it is like it is

Get the jqXhr.responseText on a jQuery getJSON request using JSONP

依然范特西╮ 提交于 2019-12-25 15:29:51
问题 I am writing a diagnostic site to test our server methods. One of the things I would like to see is the HTTP status code, and the actual payload returned. When I make a CORS request by using $.ajax, I can see the jqXhr.responseText to see the payload, but when I use $.getJSON to make a JSONP request, jqXhr.responseText is undefined. Is there any way to see the HTTP payload when using $.getJSON with jsonp? function callJavascript(url, callback) { var closedData; var jqXhr = $.getJSON(url,

Get the jqXhr.responseText on a jQuery getJSON request using JSONP

陌路散爱 提交于 2019-12-25 15:29:40
问题 I am writing a diagnostic site to test our server methods. One of the things I would like to see is the HTTP status code, and the actual payload returned. When I make a CORS request by using $.ajax, I can see the jqXhr.responseText to see the payload, but when I use $.getJSON to make a JSONP request, jqXhr.responseText is undefined. Is there any way to see the HTTP payload when using $.getJSON with jsonp? function callJavascript(url, callback) { var closedData; var jqXhr = $.getJSON(url,

Checking if web server is online/offline [duplicate]

左心房为你撑大大i 提交于 2019-12-25 08:48:28
问题 This question already has answers here : What's the best way to check if a website is up or not via JavaScript (5 answers) Closed 3 years ago . How would I check if a web server is online/offline from my domain? I've already tried an $ajax call with jsonp, but if the server isn't responding with json, then that doesn't work. Is there any other way to get an http response from a server? 回答1: Just copied shamelessly from one website for easiness: <img src="http://site-to-check.com/online.png"

JavaScript HTTP request failed

我的梦境 提交于 2019-12-24 04:06:29
问题 Could anybody take a look at below code help me to figure out what I am doing wrong ? I am getting this error error XMLHttpRequest {readyState: 1, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, responseURL: ""…} when I am trying to make a request to NASA image galary to fetch a image.. HTML: <img id="map" src="" alt="image from NASA"> JS: var get = function(url){ return new Promise(function(resolve,reject){ var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function()

How to make file upload work with jQuery and xhr2 (empty $_FILES returned)

耗尽温柔 提交于 2019-12-21 21:24:03
问题 I am using the $.ajax method and xhr2 to upload a file using the $.ajax method. When I assing any standard object to the $.ajax parameter data, a proper non empty array is returned in $_POST (php). JS: data : {name:"john doe"} PHP: print_r($_POST) Array ( [name] => john doe ) However, when I assing a formData object to the parameter data in order to upload a file, an empty array is returned in $_FILES (php) JS: data : new FormData(document.getElementById('fileupload')) PHP: print_r($_FILES)

Continue an aborted AJAX (jqXHR) request

*爱你&永不变心* 提交于 2019-12-20 06:17:55
问题 Is it possible to continue an aborted AJAX (jqXHR) request? Something like: $(document).ajaxSend(function(event, jqXHR, ajaxOptions) { if(/* it enters my conditions */) { $.current_request = jQuery.extend(true, {}, jqXHR); jqXHR.abort(); } } // some time in the future $.ajax($.current_request) This is not working, and I can see one problem that I do not know how to solve: no options are set when sending the request again. 回答1: Give it a try (not tested) var request_queue = [], is_processing =

Basic authentication using XHR

喜夏-厌秋 提交于 2019-12-19 10:16:31
问题 I am trying to get some response from my server which needs basic authentication. So when I use curl as: curl -u user:pass http://myserver.com/get/send-my-data It is giving me correct response. But when I am creating an XHR request using jquery AJAX. I am having 403 error. Here is my AJAX setup: $.ajax ({ type: 'GET', url: 'http://myserver.com/get/send-my-data', beforeSend: function(xhr) { xhr.setRequestHeader("Authorization", "Basic" + encode64(user:pass)); // I have calculated base64

How do I SET a Cookie (header) with XMLHttpRequest in JavaScript?

南笙酒味 提交于 2019-12-17 07:13:27
问题 I'm trying to set a Cookie in a XSS request using XMLHttpRequest. I found the XMLHttpRequest Specification, and section 4.6.2-5 does seem to suggest that setting Cookie, Cookie2, and some other headers are not allowed, but I was hoping there was a work around. My (jQuery) code is below, but the resulting query fails as the cookie is NOT set. $.ajax( { type : "POST", url : URL, data: SOAP_INBOX_MAIL_QUERY, dataType : "xml", async: false, beforeSend : function(xhr) { var cookie = credentials[

Incorrect jqXHR response for Jquery Forms Plugin in IE8 and 9

走远了吗. 提交于 2019-12-13 05:50:05
问题 I've got an unusual problem that I've only been able to replicate in IE8 and 9 - I've tested Safari, Chrome (both on a Mac, Firefox (on a PC) and IE8, 9 and 10. I have the following code: $('#fileStore_newUpload').ajaxForm({ beforeSubmit: function(arr, $form, options){ options.context = $form; }, dataType:'xml', success: function(responseXML,status,jqXHR){ alert(jqXHR.responseText); var xmlDoc = $.parseXML(jqXHR.responseText); $xml = $( xmlDoc ); alert($xml.find("uploadSuccess").text());