473,418 Members | 1,994 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,418 software developers and data experts.

AJAX app will not make call on Safari and FireFox, works fine on Internet Explorer, any ideas?

>From my development envrionment (i.e. a single WinXP notebook PC) I
have a basic AJAX application that is making the call to a Windows
Form page that just returns the request back to the AJAX client from
the JavaScript HttpXMLRequest
protected void Page_Load(object sender, EventArgs e)
{
string txt = "";
string input = null;
StreamReader sr = new StreamReader(Request.InputStream);
while ((input = sr.ReadLine()) != null)
{
txt += input;
input = null;
}

sr.Close();
sr.Dispose();
Response.Write(txt);
Response.End();

}

In the onreadystatechange event, once the request is returned I am
performing a simple JavaScript alert() to display back the response.
This works fine from IE when it's calling a local server either IIS or
from VS.NET 2005's ASP.NET development Server on port 2160. However
if I try to make the call to either of these servers from FireFox or
Safari it appears the call to HttpXMLRequest never goes through.

I understand there is a cross-domain restriction on HttpXMLRequest
calls in Safari and FireFox that is handled differently in IE, I
suspect this has something to do with the problem.... Any advice?

Sep 11 '07 #1
2 2727
ie will also enforce cross doamain, unless the source is trusted. often
in dev, the html source is trusted, where it will not be from a hosted
server. then IE will act like forefox and safari

-- bruce (sqlwork.com)

JDeats wrote:
>>From my development envrionment (i.e. a single WinXP notebook PC) I
have a basic AJAX application that is making the call to a Windows
Form page that just returns the request back to the AJAX client from
the JavaScript HttpXMLRequest
protected void Page_Load(object sender, EventArgs e)
{
string txt = "";
string input = null;
StreamReader sr = new StreamReader(Request.InputStream);
while ((input = sr.ReadLine()) != null)
{
txt += input;
input = null;
}

sr.Close();
sr.Dispose();
Response.Write(txt);
Response.End();

}

In the onreadystatechange event, once the request is returned I am
performing a simple JavaScript alert() to display back the response.
This works fine from IE when it's calling a local server either IIS or
from VS.NET 2005's ASP.NET development Server on port 2160. However
if I try to make the call to either of these servers from FireFox or
Safari it appears the call to HttpXMLRequest never goes through.

I understand there is a cross-domain restriction on HttpXMLRequest
calls in Safari and FireFox that is handled differently in IE, I
suspect this has something to do with the problem.... Any advice?
Sep 11 '07 #2
On Sep 11, 2:44 pm, bruce barker <nos...@nospam.comwrote:
ie will also enforce cross doamain, unless the source is trusted. often
in dev, the html source is trusted, where it will not be from a hosted
server. then IE will act like forefox and safari

-- bruce (sqlwork.com)
Bruce,

Thanks for your help.

So I guess my question is: how does the cross-domain restriction
effect non-IE browsers when you're developing and testing on
localhost. There is no domain server present in this case as I'm not
running a domain server on my XP Pro notebook where all this is
occurring, but I do need to be able to test from non-IE browsers on my
dev environment.

req.onreadystatechange = processReqChange;
req.open("POST", "SendIt.aspx", true);
alert(req.readyState); // this returns 1 on all browsers as expected,
indicating the open command was a succes
req.send("<b>data</b>");

So after the send call is made the processReqChange function gets
called.... From inside processReqChange I can test req.readyState and
it equals 4 as expected.... however if I try to get the value of
req.status an exception is thrown in FireFox, below is the code with
comments explaining what is happening at various points.

function processReqChange() {

alert("process req changed");
// this called when the page loads by IE, FireFox and Safari..... It
is called again after the req.send(...) command is issued on FireFox
and IE, but not on Safari.
if (req.readyState == 4) {
// only if "OK"

try
{
var s = req.status;
alert(s); // I can only get to this point with Internet
Explorer.

} catch (e) {
alert("failed to read status");
// this catch is always trigged from FireFox, again with
Safari this event handler methid is never even triggered after the
req.send...
}
-Jeremy

Sep 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: noballack | last post by:
I've got a problem, I'm working with Ajax in a web with a form with a list of checkbox added to the form via an Ajax.Updater method. These added checkboxs are not been sended by the form if I use...
17
by: Arjen | last post by:
Hi, I want to reload 2 divs at one click. Ive tried: <a href = "javascript:void(0);"...
21
by: Leena P | last post by:
i want to basically take some information for the product and let the user enter the the material required to make this product 1.first page test.php which takes product code and displays...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
1
by: wpt394 | last post by:
I am running a code that works just fine in Firefox, but seems to have trouble in IE. The basic idea is that a travel search process is initiated with one ajax call, and a 2nd ajax call 'updates'...
1
by: Nithu25 | last post by:
Hi All, I don't know much about Ajax.I am facing some problem while using Ajax along with JSP. From one jsp file, one function named "addtoCollect" is called which is written in a js file,...
29
by: zalek | last post by:
I am writing application with Ajax in sync mode - xmlHttp.open("GET", url, false). I noticed that in FireFox handler doesn't starts. It starts when I use xmlHttp.open("GET", url,true). I need to...
1
by: fidgen | last post by:
Hiya, I'm trying to get a AJAX driven update to my list of news articles, so when users click the title of the news article, it pops up the article content in a thickbox overlay. Retrieving...
1
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.