xmlhttprequest

IE8 AJAX GET setRequestHeaders not working unless params provided in URL

I'm trying to create an AJAX request in IE8. var xhr = new ActiveXObject( 'Msxml2.XMLHTTP' ); xhr.open( 'GET', '/ajax/' ); // Required header for Django to detect AJAX request xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest' ); xhr.onreadystatechange = function() { if ( this.readyState == 4 ) console.log(this.responseText);...

How a database is loaded into an application?

Hi All i need is a simple explanation on how does this function work I also attached a piece of php which I think is the one that retrieves the data from the database. Please correct me if I'm wrong Cheers. function loadDatabaseRecords () { // Mozilla/Safari if (window.XMLHttpRequest) { xmlHttpReq = new XMLHttpRequest(); } // ...

Are google chrome extension "content" scripts sandboxed?

I was under the impression that the content_scripts were executed right on the page, but it now seems as though there's some sandboxing going on. I'm working on an extension to log all XHR traffic of a site (for debugging and other development purposes), and in the console, the following sniff code works: var o = window.XMLHttpRequest...

How does Facebook chat avoid continuous polling of the server?

I am trying to understand how Facebook's chat feature receives messages without continuously poling the server. Firebug shows me a single GET XmlHttpRequest continuously sitting there, waiting for a response from the server. After 5 minutes, this never timed out. How are they preventing timeout? An AJAX request can just sit there like...

Multiple http digest authentications to pull camera mjpg feeds into page

I have 7 IP cameras in a building on the LAN with a Mac OS 10.6 server. The cameras are broadcasting individual mjpg feeds, which are available on individual ports outside the subnet. Each feed is protected by http digest authentication. I would like to figure out 2 things: what is the best way to display a mjpg feed in a web page? (I...

Problem with making a simple JS XmlHttpRequest call

Edit: Maybe I made the question more complex than it should. My questions is this: How do you make API calls to a server from JS. I have to create a very simple client that makes GET and POST calls to our server and parses the returned XML. I am writing this in JavaScript, problem is I don't know how to program in JS (started to look in...

Why should I reuse XmlHttpRequest objects?

From what I understand, it's a best practice to reuse XmlHttpRequest objects whenever possible. Unfortunately, I'm having a hard time understanding why. It seems that by trying to reuse XHR objects you increase your code complexity and you introduce possible browser incompatibilities. So why do so many people recommend it? After some...

getting web page data as json object?

I have a url, the data of which page i need as a json object. I ve tried xmlhttprequest and ajaxobject both but doesnt work. It doesnt even give a responseText when I give it as an alert Ill post both the code snippets here. url = http://mydomain.com:port/a/b/c AJAX : var ajaxRequest = new ajaxObject(URL); ajaxRequest.callback = funct...

Multi-Array of XML Requests

OMG, I am in need of a way to set up arrays of XML Requests based on the idShout - 1. So it would be something like this... var req = new Array(); req[idShout - 1] = ALL XML Data... Here's what I got so far but it's not working at all :( var idShout; var req = new Array(); function htmlRequest(url, params, method) { req[req.pus...

Sending POST variables through a PHP proxy for AJAX?

I've decided that using a PHP proxy for AJAX calls for a project is the best way to go - but I have a question regarding passing POST data through the proxy. As in - how to do it. Should I need to create a single variable in the javascript using alternate characters, then have the PHP proxy parse and modify the variable to reassemble...

SharePoint Designer - xmlHTTPRequest innerHTML

Hi, I have a sharepoint page that filters a data view from a query string in the address bar. I wanted to add further functionality by also returning back any of the files in the main sharepoint library that matches the query string in the address bar. I added a content editor webpart and I added a xmlHTTPRequest that imports the search...

Is Form Tag Necessary in AJAX Web Application?

I read some AJAX-Form tutorial like this. The tag form is used in HTML code. However, I believed that it is not necessary. Since we send HTTP request through XmlHttpRequest, the sent data can be anything, not necessary input in form. So, is there any reason to have form tag in HTML for AJAX application? ...

XMLHttpRequest open() returning access denied

Hi! I have problem with xhr open() method. My code follows : var xmlhttp=false; if(!xmlhttp) try { xmlhttp=new XMLHttpRequest(); } catch(e) { xmlhttp=false; } function returnPage(url) { if(!xmlhttp) return alert("Your browser doesn't seem to support XMLHttpRequests."); xmlhttp...

XmlHttpRequest in a bookmarklet returns empty responseText on GET?

I'm trying to build a javascript bookmarklet for a special URL shortening service we've built at http://esv.to for shortening scripture references (i.e. "Matthew 5" becomes "http://esv.to/Mt5". The bookmarklet is supposed to do a GET request to http://api.esv.to/Matthew+5, which returns a text/plain response of http://esv.to/Mt5. The co...

file_get_contents("php://input") or $HTTP_RAW_POST_DATA, which one is better to get the body of JSON request?

And from the client side, which request type (GET or POST) is better to use, to send JSON data if I use XmlHTTPRequest? My application use this stream of data for either retrive data form database and execute some functionality in PHP. EDIT: My question was inspired from this answer: http://stackoverflow.com/questions/813487/how-to-pos...

Get attached file content with XmlHttpRequest and Internet Explorer

I'm using XmlHttpRequest to perform a text file download, and here is the response header I have got from the server : Connection: keep-alive Transfer-Encoding: chunked Content-Disposition: attachment; filename="template" Content-Length: 244 Pragma: no-cache Cache-Control: no-cache, must-revalidate Expires: 0 Content-Encoding: deflate ...

XMLHttpRequest() and outputting csv file

I can successfully generate a csv file by issuing an html form POST to a new window and use PHP to respond with: header('Content-type: text/csv'); header('Content-Disposition: attachment; filename="'.date("Ymdhis").'.csv"'); print get_lines(); However, this leaves the the window open and blank. I want to either close the window autom...

XMLHttpRequest() and Google Analytics Tracking

I have implemented an XMLHttpRequest() call to a standalone html page which simply has an html, title & body tag which Google Analytics Tracking code. I want to track when someone makes a request to display information (i.e. phone number) to try and understand what portion of people look at my directory versus obtaining a phone number t...

Get Chinese Romanization from Google Translate API

The Google language translate API works cleanly to translate into Chinese: <script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt; <script> google.load('language','1'); function googletrans(text) { google.language.translate(text,'en','zh',function(result) { alert(result.translation); }); }...

XMLHttpRequest.status always returning 0

html <a href="#" onclick="MyObj.startup()">click me</a> js code var MyObj = { startup : function() { var ajax = null; ajax = new XMLHttpRequest(); ajax.open('GET', 'http://www.nasa.gov', true); ajax.onreadystatechange = function(evt) { if(ajax.readyState == 4) {...