Search Results

Search found 535 results on 22 pages for 'xmlhttprequest'.

Page 5/22 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • [Simple] Beginner AJAX script not working, stuck on opening XMLHttpRequest

    - by Julian H. Lam
    Hopefully, this question isn't too juvenile to ask - but here goes: I'm trying to learn AJAX, and I'm stuck on a simple content-fetch. Here is my code: request = getHTTPObject(); function useHttpResponse() { if (request.readyState == 4) { document.getElementById("p").innerHTML = request.responseText; } } function update_p() { request.open("GET",content.html,true); request.onreadystatechange = useHttpResponse; } getHTTPObject is correctly defined, and returns a proper XMLHttpObject. As you probably guessed from the excerpt, the element I am trying to update is id'd "p". It calls the script correctly when a button is clicked, no problem there. The script seems to stop at line 8, at request.open. There's no error, and the script silently ignores anything afterward. I don't think I've missed anything, but of course, I probably did. Where did I go wrong? Thanks!

    Read the article

  • Comet with multiple channels

    - by mark_dj
    Hello, I am writing an web app which needs to subscribe to multiple channels via javascript. I am using Atmosphere and Jersey as backend. However the jQuery plugin they work with only supports 1 channel. I've start buidling my own implementation. Now it works oke, but when i try to subscribe to 2 channels only 1 channel gets notified. Is the XMLHttpRequest blocking the rest of the XMLHttpRequests? Here's my code: function AtmosphereComet(url) { this.Connected = new signals.Signal(); this.Disconnected = new signals.Signal(); this.NewMessage = new signals.Signal(); var xhr = null; var self = this; var gotWelcomeMessage = false; var readPosition; var url = url; var onIncomingXhr = function() { if (xhr.readyState == 3) { if (xhr.status==200) // Received a message { var message = xhr.responseText; console.log(message); if(!gotWelcomeMessage && message.indexOf("") -1) { gotWelcomeMessage = true; self.Connected.dispatch(sprintf("Connected to %s", url)); } else { self.NewMessage.dispatch(message.substr(readPosition)); } readPosition = this.responseText.length; } } else if (this.readyState == 4) { self.disconnect(); } } var getXhr = function() { if ( window.location.protocol !== "file:" ) { try { return new window.XMLHttpRequest(); } catch(xhrError) {} } try { return new window.ActiveXObject("Microsoft.XMLHTTP"); } catch(activeError) {} } this.connect = function() { xhr = getXhr(); xhr.onreadystatechange = onIncomingXhr; xhr.open("GET", url, true); xhr.send(null); } this.disconnect = function() { xhr.onreadystatechange = null; xhr.abort(); } this.send = function(message) { } } And the test code: var connection1 = AtmosphereConnection("http://192.168.1.145:9999/botenveiling/b/product/status/2", AtmosphereComet); var connection2 = AtmosphereConnection("http://192.168.1.145:9999/botenveiling/b/product/status/1", AtmosphereComet); var output = function(msg) { alert(output); }; connection1.NewMessage.add(output); connection2.NewMessage.add(output); connection1.connect(); In AtmosphereConnection I instantiate the given AtmosphereComet with "new". I iterate over the object to check if it has to methods: "send", "connect", "disconnect". The reason for this is that i can switch the implementation later on when i complete the websocket implementation :) However I think the problem rests with the XmlHttpRequest object, or am i mistaken? P.S.: signals.Signal is a js observer/notifier library: http://millermedeiros.github.com/js-signals/ Testing: Firefox 3.6.1.3

    Read the article

  • using xmlHttpRequest.send() in java script

    - by harun123
    How to use xmlHttp Request.send()?...... My code in java script is as follows: str_xml+="<xml_to_be_submitted><request_xml><client_id>"+document.frmCallEntryAdd.cboCLIENT.options[document.frmCallEntryAdd.cboCLIENT.selectedIndex].value+"</client_id></request_xml></xml_to_be_submitted>"; var obj_http=new ActiveXObject("Microsoft.XMLHTTP"); var str_url="ClientModuleFetch.aspx"; var str_http_method="post"; obj_http.open(str_http_method,str_url,false); obj_http.SetRequestHeader("Content-Type","application/x-www-form-urlencoded"); obj_http.send(str_xml); var str_reply=obj_http.ResponseText; var xmlResponse = str_reply; var objXmlDOM=new ActiveXObject("Microsoft.XMLDOM"); Can any body tell what i had gone wrong?................

    Read the article

  • adding results of XML request to a page

    - by user2925833
    I am trying to get a feel for adding content to a page with XMLHTTPRequest. I would like to add the results to existing page content say in a second column, but I am not having any luck. I would appreciate a shove in the right direction. Thanks for any help. <!DOCTYPE html> <html> <head> <style> #button{ float: left; } #team{ float: left; } </style> <title>XMLHTTPRequest</title> <script src="jquery-1.10.2.js"></script> <script> $(document).ready(function(){ xhr = new XMLHttpRequest(); xhr.onreadystatechange = function(){ if (xhr.readyState == 4 && xhr.status == 200) { xmlDoc = xhr.responseXML; var team = xmlDoc.getElementsByTagName("teammember"); var html = ""; for (i = 0; i < team.length; i++){ html += xmlDoc.getElementsByTagName("name")[i].childNodes[0].nodeValue + "<br>" + xmlDoc.getElementsByTagName("title")[i].childNodes[0].nodeValue + "<br>" + xmlDoc.getElementsByTagName("bio")[i].childNodes[0].nodeValue + "<br><br>"; } //this is the code I would like help with var team = document.getElementById("team"); team.appendChild(document.createTextNode("html")); } } xhr.open("GET", "team.xml", true); }); </script> </head> <body> <div id="button"> <button onclick="xhr.send()">Click Me!</button> </div> <div id="team"> </div> </body> </html>

    Read the article

  • Checking validation errors in XMLHttpRequest

    - by egaga
    $.post(actionUrl, serializedForm, function(response) { ... } I need to check whether validation of form succeeded, or not (I don't need to know the exact validation errors). The validation is done by Spring, and I wouldn't like to interfere the process, because there's some annoying dependencies. What would be the best approach? Is there a Spring error object in response, or is it accessible only in server side? I would also like to know if there's is any proper documentation about response in jQuery site? How can I traverse or manipulate it?

    Read the article

  • how do I access XHR responseBody from Javascript?

    - by Cheeso
    I've got a web page that uses XMLHttpRequest to download a binary resource. Because it's binary I'm trying to use xhr.responseBody to access the bytes. I've seen a few posts suggesting that it's impossible to access the bytes directly from Javascript. This sounds crazy to me. Weirdly, xhr.responseBody is accessible from VBScript, so the suggestion is that I must define a method in VBScript in the webpage, and then call that method from Javascript. See jsdap for one example. var IE_HACK = (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)); if (IE_HACK) document.write('<script type="text/vbscript">\n\ Function BinaryToArray(Binary)\n\ Dim i\n\ ReDim byteArray(LenB(Binary))\n\ For i = 1 To LenB(Binary)\n\ byteArray(i-1) = AscB(MidB(Binary, i, 1))\n\ Next\n\ BinaryToArray = byteArray\n\ End Function\n\ </script>'); var xml = (window.XMLHttpRequest) ? new XMLHttpRequest() // Mozilla/Safari/IE7+ : (window.ActiveXObject) ? new ActiveXObject("MSXML2.XMLHTTP") // IE6 : null; // Commodore 64? xml.open("GET", url, true); if (xml.overrideMimeType) { xml.overrideMimeType('text/plain; charset=x-user-defined'); } else { xml.setRequestHeader('Accept-Charset', 'x-user-defined'); } xml.onreadystatechange = function() { if (xml.readyState == 4) { if (!binary) { callback(xml.responseText); } else if (IE_HACK) { // call a VBScript method to copy every single byte callback(BinaryToArray(xml.responseBody).toArray()); } else { callback(getBuffer(xml.responseText)); } } }; xml.send(''); Is this really true? The best way? copying every byte? For a large binary stream that's not gonna be very efficient. There is also a possible technique using ADODB.Stream, which is a COM equivalent of a MemoryStream. See here for an example. It does not require VBScript but does require a separate COM object. if (typeof (ActiveXObject) != "undefined" && typeof (httpRequest.responseBody) != "undefined") { // Convert httpRequest.responseBody byte stream to shift_jis encoded string var stream = new ActiveXObject("ADODB.Stream"); stream.Type = 1; // adTypeBinary stream.Open (); stream.Write (httpRequest.responseBody); stream.Position = 0; stream.Type = 1; // adTypeBinary; stream.Read.... /// ???? what here } I don't think that's gonna work - ADODB.Stream is disabled on most machines these days. In The IE8 developer tools - the IE equivalent of Firebug - I can see the responseBody is an array of bytes and I can even see the bytes themselves. The data is right there. I don't understand why I can't get to it. Is it possible for me to read it with responseText? hints? (other than defining a VBScript method)

    Read the article

  • WCF Restful services getting error 400 (bad request) when post xml data

    - by Wayne Lo
    I am trying to self host a WCF services and calling the services via javascript. It works when I pass the request data via Json but not xml (400 bad request). Please help. Contract: public interface iSelfHostServices { [OperationContract] [WebInvoke(Method = "POST", UriTemplate = INFOMATO.RestTemplate.hello_post2,RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped)] Stream hello_post2(string helloString); } Server side code: public Stream hello_post2(string helloString) { if (helloString == null) { WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.BadRequest; return null; } WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK; return new MemoryStream(Encoding.UTF8.GetBytes(helloString)); } JavaScript: function testSelfHost_WCFService_post_Parameter() { var xmlString = "<helloString>'hello via Post'</helloString>"; Ajax_sendData("hello/post2", xmlString); } function Ajax_sendData(url, data) { var request = false; request = getHTTPObject(); if (request) { request.onreadystatechange = function() { parseResponse(request); }; request.open("post", url, true); request.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); charset=utf-8"); request.send(data); return true; } } function getHTTPObject() { var xhr = false; if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } else if (window.ActiveXObject) {...} }

    Read the article

  • Do I need jsonp?

    - by franziga
    Since firefox 3, cross domain XmlHttpRequest is available. As my understand, jsonp is also doing something about cross domain. If I only need to deal with firefox 3, do I still need to use jsonp?

    Read the article

  • Xsl mime type problem

    - by savruk
    Hi, I have a busybox with lighttpd running on as http server. My problem is while firefox and opera can get the page with applied xsl, Arora(webkit) can not. Here is the script I use to get it work: <html> <head> <script> function loadXMLDoc(dname) { if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest(); } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("GET",dname,false); xhttp.send(""); return xhttp.responseXML; } function querySt(ji) { hu = window.location.search.substring(1); gy = hu.split("&"); for (i=0;i<gy.length;i++) { ft = gy[i].split("="); if (ft[0] == ji) { return ft[1]; } } } function displayResult() { xml=loadXMLDoc("sample.xml"); alert(xml)//Gives [object Document] $scan=querySt("scan"); $sub = querySt("sub"); xsl=loadXMLDoc("sample.xsl"); alert(xsl)//Gives Null // code for IE if (window.ActiveXObject) { ex=xml.transformNode(xsl); document.getElementById("example").innerHTML=ex; } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xsltProcessor=new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); xsltProcessor.setParameter(null,"scan",$scan) if($sub != ""){ xsltProcessor.setParameter(null,"sub",$sub) } resultDocument = xsltProcessor.transformToFragment(xml,document); document.getElementById("example").appendChild(resultDocument); } } </script> </head> <body onload="displayResult()"> <div id="example" ></div> </body> </html> I tried to see if it load xsl well and put an alert(xsl) but it gives null. Other browser can get xml and xsl files perfectly. What can be the problem? Thanks P.S: It runs well on my local server with all browser.

    Read the article

  • javascript conflict on accesing DOM

    - by justjoe
    i read this statement from a book i read The Document Object Model or DOM is really not a part of JavaScript but a separate entity existing outside it. Although you can use JavaScript to manipulate DOM objects, other scripting languages may equally well access them too. what is the best way to avoid conflict between javascript and other client-siede scripting language when we have to deal with XMLHTTPRequest object

    Read the article

  • How a database is loaded into an application?

    - by Audel
    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(); } // IE else if (window.ActiveXObject) { xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } alert ("To Server (Load Records):\n\najax-open-DB.php"); xmlHttpReq.open('GET', "ajax-open-DB.php", true); xmlHttpReq.onreadystatechange = loadDatabaseRecordsCallback; xmlHttpReq.send(null); } <?php $link = mysql_connect ("ipaddress", "localhost", "password"); mysql_select_db ("database1"); $query = "SELECT * from addressbook"; $result = mysql_query ($query); print "<table>"; print "<tr>"; print "<th>Firstname</th><th>Lastname</th><th>Address</th><th>Telephone</th>"; print "</tr>"; for ($i = 0; $i < mysql_num_rows ($result); $i ++) { $row = mysql_fetch_object ($result); print "<tr>"; print "<td>$row->firstname</td>"; print "<td>$row->lastname</td>"; print "<td>$row->address</td>"; print "<td>$row->telephone</td>"; print "</tr>"; } print "</table>"; mysql_close ($link); ?>

    Read the article

  • How to unset an ajax loading.

    - by metacortex
    Hi, I have this script which loads external content: <script type="text/javascript"> var http_request = false; function makePOSTRequest(url, parameters) { http_request = false; if (window.XMLHttpRequest) { http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open('POST', url, true); http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request.setRequestHeader("Content-length", parameters.length); http_request.setRequestHeader("Connection", "close"); http_request.send(parameters); } function alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { result = http_request.responseText; document.getElementById('opciones').innerHTML = result; } else { alert('Hubo un problema con la operación.'); } } } function get(obj) { var poststr = "port_post=" + encodeURI( document.getElementById("port-post").value ); makePOSTRequest('http://www.site.com/inc/metaform.php?opcion='+ encodeURI( document.getElementById("port-post").value ), poststr); } </script> This is the select that retrieves the content: <select name="port_post" id="port-post" onchange="get(this.parentNode);"> <option value="1">Select one...</option> <option value="2">Pear</option> <option value="3">Pineapple</option> </select> And this is the container div: <div id="opciones">Default content</div> All I whish to know is how I can unset the ajax loading when I change the selection to "Select one...". I wish to say, how restoring the Default content once the "Select one..." option is selected.

    Read the article

  • why multipart/x-mixed-replace is needed for Comet?

    - by Morgan Cheng
    I'm reading this article about Comet http://en.wikipedia.org/wiki/Comet_(programming). It mentions that browser should support multipart/x-mixed-replace to make XmlHttpRequest Streaming possible. Why this multipart/x-mixed-replace is necessary? Without this header, HTTP response can still be chunked and sent piece by piece to browser, right?

    Read the article

  • Is Form Tag Necessary in AJAX Web Application?

    - by Morgan Cheng
    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?

    Read the article

  • How to Automatically Refresh Data on Page Using Ajax on an Interval?

    - by Karnak
    I would like to load an XML file every 30 seconds and display its contents inside an HTML page. So far I know how to load the file, but I don't know how to automatically refresh it and display its updated contents. It would also be great if it did some error checking and if it displayed error.png image when it's not able to load data.xml file. Here is my code: <head> <script> window.XMLHttpRequest { xmlhttp = new XMLHttpRequest(); } xmlhttp.open("GET", "data.xml", false); xmlhttp.send(); loadXMLDoc = xmlhttp.responseXML; f = loadXMLDoc.getElementsByTagName("foo") function buildBar(i) { qux = (f[i].getElementsByTagName("qux")[0].childNodes[0].nodeValue); document.getElementById("displayBar").innerHTML = qux; } </script> </head> <body> <script> document.write("<ul>"); for (var i = 0; i < f.length; i++) { document.write("<li onclick='buildBar(" + i + ")'>"); document.write(f[i].getElementsByTagName("bar")[0].childNodes[0].nodeValue); document.write("</li>"); } document.write("</ul>"); </script> <div id="displayBar"> </div> </body> After searching the internet for a few hours I found many examples on how to do this, but I didn't know how to implement it in my particular case. I am not a programmer, so please be kind. I would really appriciate any help. It would mean a lot.

    Read the article

  • Headers to set for AJAX calls in a custom webserver

    - by ErJab
    I'm writing a custom web server. When I enter the URL of my server in the browser, I get the sample text I write out to the socket in my browser correctly. This is the HTTP response that I write: HTTP/1.1 200 OK\r\n Server: My Server\r\n Date: Blah\r\n \r\n This is some sample text. This appears in my browser correctly when I connect directly to the server entering the URL. However, if I use Ajax (jQuery) to access the same URL and then set the innerHTML of an element on the HTML page, I do not get any data printed. Is there any other header I need to set on my web server so that the browser's XMLHttpRequest object detects the response?

    Read the article

  • How to access WebMethods in ASP.NET

    - by Quandary
    When i define an AJAX WebMethod like this in an ASPX page (ui.aspx): [System.Web.Services.WebMethod(Description = "Get Import Progress-Report")] [System.Web.Script.Services.ScriptMethod(UseHttpGet = false, ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)] public static string GetProgress() { System.Web.Script.Serialization.JavaScriptSerializer JSONserializer = new System.Web.Script.Serialization.JavaScriptSerializer(); return JSONserializer.Serialize("an Object/Instance here"); } // End WebMethod-Function GetProgress Can I access the description for the corresponding service somewhere ? E.g. when I want to call the webmethod with my own JavaScript, how do I do that ? I investigated the axd files, and found the xmlhttprequest to open ui.aspx/GetProgress But when I type the address in my browser, I get redirected to ui.aspx

    Read the article

  • IE8 AJAX GET setRequestHeaders not working unless params provided in URL

    - by bobthabuilda
    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); } xhr.send( null ); This works perfectly fine in Firefox, Chrome, Safari. In IE8 however, all of my AJAX test requests work EXCEPT for ones where I'm performing GETs without any query string params (such as the one above). POSTs work without question, and GET requests only work whenever I include query strings in the URL, like this: xhr.open( 'GET', '/ajax/?foo=bar' ) I'm also 110% positive that my server code is handling these requests appropriately, so, this stumps me completely. Does anyone have any clue as to what might be causing this?

    Read the article

  • How does Facebook chat avoid continuous polling of the server?

    - by Chad Johnson
    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 that indefinitely, waiting for a response? Can I do this with JSONRequest? I see this at json.org: JSONRequest is designed to support duplex connections. This permits applications in which the server can asynchronously initiate transmissions. This is done by using two simultaneous requests: one to send and the other to receive. By using the timeout parameter, a POST request can be left pending until the server determines that it has timely data to send. Or is there another way to let an AJAX call just sit there, waiting, besides using JSONRequest?

    Read the article

  • Firefox extension: how to read a cookie name and value on the current page

    - by encryptor
    My extension works on an application, which requires user login. Once the user has logged in, I need to read the cookies and use them in my XMLHttpRequests. So initially I need to check if the cookie is set, if not, I direct the user to the login page. Once logged in, I need to read the cookies and send it as part of my further requests. How do I read cookies from a XMLHttpRequest or otherwise (if we don't even know the name of the cookie) There is to function as getRequestHeader.. but what I need is something like that.

    Read the article

  • Retreiving data from MySQL with html/javaScript on one domain and the PHP file on the other

    - by Mike
    I need to retrieve data from a MySQL database, and have it work one way for all types of servers. For example it should work on a server that runs no server side language, it should also work on LAMP, and IIS. I was thinking about using ajax and xmlhttprequest, but learned of the cross domain limitation. I also tried to just include the PHP in a tag, but it comes back with a syntax error in the HTML code created by the PHP file, even though it looks correct. Does anyone know how to fix either of these issues, or have a different way to go about it?

    Read the article

  • Best way to store data for Greasemonkey based crawler?

    - by Björn
    I want to crawl a site with Greasemonkey and wonder if there is a better way to temporarily store values than with GM_setValue. What I want to do is crawl my contacts in a social network and extract the Twitter URLs from their profile pages. My current plan is to open each profile in it's own tab, so that it looks more like a normal browsing person (ie css, scrits and images will be loaded by the browser). Then store the Twitter URL with GM_setValue. Once all profile pages have been crawled, create a page using the stored values. I am not so happy with the storage option, though. Maybe there is a better way? I have considered inserting the user profiles into the current page so that I could all process them with the same script instance, but I am not sure if XMLHttpRequest looks indistignuishable from normal user initiated requests.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >