xhr

Is monitoring location.hash a solution for history in XHR apps?

As is well known, in XHR (aka AJAX) web applications no history for your app is build and clicking the refresh button often moves the user out of his/her current activity. I stumbled upon location.hash (e.g. http://anywhere/index.html#somehashvalue) to circumvent the refresh problem (use location.hash to inform your app of it's current s...

Safari: Submit form using xhrPost when the Enter key is pressed

I have bound a JavaScript function to the submit button of a form, causing the form to be submitted via an xhrPost request (using Dojo). However, when the user hits "Enter" in Safari, the form is submitted the usual way. Is there any way to prevent Safari from submitting the form when the Enter key is pressed? Can I somehow bind my Java...

Ajax (or JSONP) on unload with Safari/Chrome

If you try to send an Ajax request, a JSONP request, or even a window.name request on unload, Safari and Chrome run the code, but the server never sees the request. My theory is the thread of execution never allows the script tag to run before it changes the page. Here is a test page with the JSONP test. This code (and Ajax and window...

XmlHttpRequest vs cURL

I was wondering if anyone has done any testing on the speed differences of cURL and XHR (in regards to the time it takes to complete a request, or series of requests). Specifically I'm wondering because I would like to use XHR to go to php script, and use cURL from there to grab a resource. The php page will ensure ensuring the data is ...

json xhr response opens a download file popup window

Hi For one of our ajax request (with a .json response) some of our clients have complained that they are seeing a "File Download" prompt asking the user to download the .json response. I am baffled because considering that this is an xhr response, this should never happen. Has anyone seen this? Thanks ...

write an IE XHR proxy in javascript

Problem: I am looking for a way to intercept xhr.open() calls I am writing a framework which will run along side exiting code, over which i have no control I need to intercept the open calls in this existing code. I cannot change the existing code I must thus override the native XHR implementation for both IE and Firefox. I have made...

Is there any advantage of AJAX/XHR over pure JSON/P implementations?

Not strictly a programming topic but input is appreciated. I've been developing a lot lately with YouTube APIs and I started with PHP code, using SimpleXML, then actually skipped AJAX and went straight to using native JSON and doing everything client-side. While it "feels" faster, I wonder if it's ready for primetime yet. Even with t...

Is it possible to send custom headers with an XHR ("Ajax" request)?

I'm working with an API which needs extra security information sent along with an HTTP request as meta-information in headers. Is it possible to set those in an XMLHttpRequest? ...

Why is Firefox removing the form tags from an XHR?

I have an XHR inside of a form on my webpage that returns a Lightbox with another form in it. In Safari/Webkit, everything works great, and the form submits as expected. However, on Firefox 3/3.5, using Firebug to look at the source, it appears that the tags have been stripped out of the XHR. I KNOW that my app is generating the form...

Intercepting XHRs

Is it possible to intercept when the browser does a XHR? Regardless of JavaScript libraries used? Like setTimeout(function() { // jQuery XHT $('#container').load('foo.html'); }, 5000); When the jQuery.load fires, I want to intercept this and add an url parameter to the request. Thanks in advance for tips and info. Best regards ...

Any way to prevent Safari and Chrome to show loading animation while XHR is active?

I'm using XMLHTTPRequest binding to receive asynchronous events from the server. XHR opens a server URI and then hangs until an event comes or timeout occurs, in any case JS fires a new XHR on the same URI immediately. This works fine, but there is an annoying problem in Safari and Chrome: both keep showing "page loading" animation whil...

access denied using asp's MSXML2.XMLHTTP

Set oXMLHttp=Server.CreateObject("MSXML2.XMLHTTP") On Error Resume Next oXMLHttp.open "GET", "http://xxxxxx.com",False oXMLHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" oXMLHttp.send() x = oXMLHttp.responseText I'm getting this error: Access Denied ...

Simulating an XHR GET request

In my RSpec tests, I need to simulate an AJAX GET request to the index action, and have been using the code as described in both the Rails docs and the RSpec book: xhr :get, :index This always fails though, as the test tries to load the show action (without any parameters) rather than the specified index action. The controller action...

How to debug XHR POST requests in Safari 4?

I've got an XHR request that's succeeding in FF3.5 but apparently failing when done in Safari 4. I'm looking at the xhr requests in the debugger in Safari, and Firebug in Firefox. So on the backend service that's being hit, if the username and password are missing from the POST parameter then the service gives a 500 error. If the parame...

jQuery AJAX fires error callback on window unload?

If I navigate away from a page in the middle of an $.ajax() request it fires the error callback. I've tested in Safari and FF with both GET and POST requests. It has been suggested that one could abort all AJAX requests on page unload but the error handler is actually called first so it doesn't seem possible nor practical. This is pro...

Detect XHR error is really due to browser stop or click to new page

While my page is loading content via XHR, if the user clicks the stop button or clicks to go to another page, the XHR error() function is called. This wouldn't normally be a big deal except for the user shock of seeing lots of (red) error messages on the page. The messages are valid - there was indeed an error retrieving the content - b...

[DOJO] xhrPost : from an http view to an https url

Hi, using Dojo, is it possible to make an Ajax call using xhrPost from an HTTP view to a HTTPS url ? The url must be HTTPS (as defined in Struts). If I simply set "MyCommand" as the 'url' parameter of the xhrGet, I get a 302 error code. If I transform "MyCommand" using javascript to something like "https://......./servlet/MyCommand"...

Servlet --x--> Ajax: Ajax code not receiving servlet response.

Hello - I'm unable to figure out what is going on here in this ultra simple example. Problem Summary: I have a simple servlet that appears to run just fine if I drive it manually... by issuing its URL from the browser. By 'just fine' I mean: I can see in the browser HTML page whatever I write in the servlet response. However, if I issu...

jquery and xhr.abort

When aborting an ajax request with the xhr that's passed back from the jQuery.ajax function, firebug shows that it's still trying to load that request. It doesn't block any more requests that are made, but it also doesn't show that it ever completes the request. Is this just a firebug problem? ...

Difference in jQuery with XML namespace and xhr.responseXML between Opera and Firefox

Consider this: <!DOCTYPE HTML> <html><head><title>XML-problem</title> <script src="jquery-1.3.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { $('<p/>').load("text.xml", function(responseText, textStatus, xhr) { var xml = $(xhr.responseXML); var x_txt = xml.find('atom\\:x')...