Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > AJAX app will not make call on Safari and FireFox, works fine on Internet Explorer, any ideas?

Reply
Thread Tools

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

 
 
JDeats
Guest
Posts: n/a
 
      09-11-2007
>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?

 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      09-11-2007
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?
>

 
Reply With Quote
 
 
 
 
JDeats
Guest
Posts: n/a
 
      09-11-2007
On Sep 11, 2:44 pm, bruce barker <(E-Mail Removed)> wrote:
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridview pressing Edit do not show any editable editbox in grid, while delete works fine qa4ever ASP .Net Web Controls 3 04-16-2008 10:29 PM
App cannot access the internet when run on Vista but works fine on Jon Prisbe ASP .Net Security 0 02-15-2008 06:15 PM
App configured as 2.0, throws event implying running as 1.1 in .net form browser control, works fine in IE jeremy ASP .Net 5 08-28-2006 10:30 AM
JavaScript not working in IE and Safari, works in Firefox fine. dpodkuik@gmail.com Javascript 4 02-18-2006 12:51 AM
search engine works fine on internet but not locally piet Javascript 0 06-30-2003 07:38 PM



Advertisments