473,386 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to use xdomain request on the ie 8.0

Hi All,

Till the internet explorer 7.0 the ajax request was working fine. but on the new ie 8.0 i tried to use the xdomain object request. But it fails out throwing an error. I dont understand why the error is caused.

Here is my piece of code:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <script type="text/javascript">
  3.     var xdr;
  4.  
  5.     function readdata()
  6.     {
  7.         var dRes = document.getElementById('dResponse');
  8.         dRes.innerText = xdr.responseText;
  9.         alert("Content-type: " + xdr.contentType);
  10.         alert("Length: " + xdr.responseText.length);
  11.     }
  12.  
  13.     function err()
  14.     {
  15.         alert("XDR onerror");
  16.     }
  17.     function timeo()
  18.     {
  19.         alert("XDR ontimeout");
  20.     }
  21.     function loadd()
  22.     {
  23.         alert("XDR onload");
  24.         alert("Got: " + xdr.responseText);
  25.     }
  26.     function progres()
  27.     {
  28.         alert("XDR onprogress");
  29.         alert("Got: " + xdr.responseText);
  30.     }
  31.  
  32.     function stopdata()
  33.     {
  34.         xdr.abort();
  35.     }
  36.  
  37.     function mytest()
  38.     {
  39.         var url = document.getElementById('tbURL');
  40.         var timeout = document.getElementById('tbTO');
  41.         if (window.XDomainRequest)
  42.         {
  43.             xdr = new XDomainRequest();
  44.             if (xdr)
  45.             {
  46.                 xdr.onerror = err;
  47.                 xdr.ontimeout = timeo;
  48.                 xdr.onprogress = progres;
  49.                 xdr.onload = loadd;
  50.  
  51.                 xdr.timeout = tbTO.value;
  52.                 xdr.open("GET", tbURL.value);
  53.                 xdr.send();
  54.             }
  55.             else
  56.             {
  57.                 alert('Failed to create');
  58.             }
  59.         }
  60.         else
  61.         {
  62.             alert("XDR doesn't exist");
  63.         }
  64.     }
  65. </script>
  66. <body>
  67.     <h2>XDomainRequest</h2>
  68.     <input type="text" id="tbURL" value="http://localhost/testajax/testscript.php?p=10" style="width:300px"><br>
  69.     <input type="text" id="tbTO" value="10000"><br>
  70.     <input type="button" onclick="mytest()" value="Get">&nbsp;&nbsp;&nbsp;
  71.     <input type="button" onclick="stopdata()" value="Stop">&nbsp;&nbsp;&nbsp;
  72.     <input type="button" onclick="readdata()" value="Read">
  73.     <br>
  74.     <div id="dResponse"></div>
  75. </body>
  76. </html>

I tried changing the URL to ip address,localhost and domain name but it does not work. If any one has any ideas please reply back.

Regards,
Anubhav
Apr 13 '09 #1
4 3841
acoder
16,027 Expert Mod 8TB
What's the error message?

Have you been through this page, e.g. have you set the Access-Control-Allow-Origin header?
Apr 13 '09 #2
The error is get is

XDR onerror.

i did not get as what is Access-Control-Allow-Origin header, i have tried whatever i could get on the net and google . i will look at your link also and keep you updated.

Regards,
Anubhav
Apr 13 '09 #3
hi acoder,

you made my day...i gave the following line in the first of my server code:

header("Access-Control-Allow-Origin:*"); and it started working.. thanks a lot.

Regards,
Anubhav Jha
Apr 13 '09 #4
acoder
16,027 Expert Mod 8TB
Glad to have done! :)
Apr 13 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Christopher Brandsdal | last post by:
Hi! I get an error when I run my code Is there any other way to get te information from my form? Heres the error I get and the code beneath. Line 120 is market with ''''''''''''Line...
4
by: SP | last post by:
Hi I have a problem with a customer's XML being submitting to me in a non-well-format XML. They said that there are 18 other partners who has been able to tweak the XML to make it work. So I...
7
by: Shapiro | last post by:
I have a scenario where I log a resquest to a database table and update the request with a corresponding response including the response time. I am using an HttpModule to do this. My challenge...
5
by: dougwig | last post by:
I'm trying to handle the scenario where a user's session times out and and their ajax request triggers a redirection by the webserver (302 error?). I'm using Prototype 1.4 and the my works great...
4
by: Michael Kujawa | last post by:
I am using the following to create an SQL statement using the names and values from request.form. The loop goes through each item in request.form The issue comes in having an additional "and" at...
6
by: santhoskumara | last post by:
How to request to servlet from Ajax and also I got the DOM object in the servlet through Business Logic. Now how will i pass the DOM object from serlvet to Clientside. Where in the client Side i am...
2
by: MDANH2002 | last post by:
Hi From VB.NET I want to simulate the POST request of the following HTML form <html> <title>HTTP Post Testing</title> <body> <form action=http://www.example.com/postdata ...
5
by: chromis | last post by:
Hi there, I've recently been updating a site to use locking on application level variables, and I am trying to use a commonly used method which copies the application struct into the request...
3
by: Joseph Geretz | last post by:
I'm using the Request Filter documentation which can be found here: http://msdn.microsoft.com/en-us/library/system.web.httprequest.filter.aspx In this example, two filters are installed, one...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.