By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

Problem with other browsers than Safari

P: n/a
Hi,

So far I wrote a few little things in javascript, but I got a small
problem with the following code. Apperently, only Apple's Safari is
handling the following code correctly. I took it from a webpage, and
modified it a bit (just the request line). I might have made some basic
mistake there.

My questions is especially concerning th following piece of code. There
seems to be a problem in the line with http.open(). At least if I put
an alert() message before it it pops-up, after it it does not show.

function getPriority2(code){
http.open('get', 'appointment_support.php?level=2&code='+ code
+'&idone='+ document.registration.priority1.value );
http.onreadystatechange = handlePriority2;
http.send(null);
}

Is there anybody who has an idea about how make it working in all
browsers? Below you find my whole javascript code. It refers to a php
page (from which I know it is working correctly - got a lot more
experience there than with javascript).

I would highly appriciate any help!

Thanks in advance!!!!

Regards,
Jochem

------------------
My code
------------------
function createRequestObject(){
var request_o; //declare the variable to hold the object.
var browser = navigator.appName; //find the browser name
if(browser == "Microsoft Internet Explorer"){
request_o = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_o = new XMLHttpRequest();
}
return request_o; //return the object
}

var http = createRequestObject();

function getPriority1(code){
http.open('get', 'appointment_support.php?code='+ code );
http.onreadystatechange = handlePriority1;
http.send(null);
}

function handlePriority1(){
if(http.readyState == 4){
var response = http.responseText;
document.getElementById('priorities').innerHTML = response;
}
}

// UNTIL HERE IT SEEMS TO BE WORKING FINE!!!!

// Get priority 2
function getPriority2(code){
// alert('shit');

http.open('get', 'appointment_support.php?level=2&code='+ code
+'&idone='+ document.registration.priority1.value );
http.onreadystatechange = handlePriority2;
http.send(null);
}

function handlePriority2(){
if(http.readyState == 4){
var response = http.responseText;
document.getElementById('priorities').innerHTML = response;
}
}

// Get priority 3
function getPriority3(code){
http.open('get', 'appointment_support.php?level=3&code='+ code
+'&idone='+ document.registration.priority1.value +'&idtwo='+
document.registration.priority2.value );
http.onreadystatechange = handlePriority2;
http.send(null);
}

function handlePriority3(){
if(http.readyState == 4){
var response = http.responseText;
document.getElementById('priorities').innerHTML = response;
}
}

Oct 19 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
you need to pass a third variable in your http.open call, true, that
tells to connect asynchronously. i think that should solve the problem,
if not, post a reply.

You may also want to try the code at
http://jibbering.com/2002/4/httprequest.html , which handles the two
different IE interfaces to ajax used by different versions of IE.
(Microsoft can't even adhere to their own standards!)

Oct 20 '05 #2

P: n/a
Joshie Surber said the following on 10/19/2005 9:34 PM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.
you need to pass a third variable in your http.open call, true, that
tells to connect asynchronously. i think that should solve the problem,
if not, post a reply.

You may also want to try the code at
http://jibbering.com/2002/4/httprequest.html , which handles the two
different IE interfaces to ajax used by different versions of IE.
It also covers a lot more than that....
(Microsoft can't even adhere to their own standards!)


I love this anti-MS shit. MS sticks to the same method, people complain
about it using old technology. They update and people complain about MS
not adhering to their own standards.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 20 '05 #3

P: n/a

Joshie Surber wrote:
you need to pass a third variable in your http.open call, true, that
tells to connect asynchronously. i think that should solve the problem,
if not, post a reply.

You may also want to try the code at
http://jibbering.com/2002/4/httprequest.html , which handles the two
different IE interfaces to ajax used by different versions of IE.
(Microsoft can't even adhere to their own standards!)


Apprently, my javascript code was correct, but I made a basic mistake
in my HTML form. For Safari 2.0 it is sufficient that a <form
id="registration"> However, any other browser needs a name="'. Can't
blame them for that. I might wanna sleep a bit more....

Oct 20 '05 #4

P: n/a
Jochem Donkers wrote:
Apprently, my javascript code was correct, but I made a basic mistake
in my HTML form. For Safari 2.0 it is sufficient that a <form
id="registration"> However, any other browser needs a name="'.
That's just not true. One can access `form' element objects by ID within
the `document.forms' collection in Mozilla Firefox, for example. That is
because the `name' attribute is not #REQUIRED for `form' elements in Valid
HTML 4/XHTML 1.x.

Your problem is instead that you are using proprietary referencing which
is likely to differ in support between user agents. Instead of

document.registration.priority1.value

use the standardized

document.forms['registration'].elements['priority1'].value

and everything should work smoothly even without `name' attributes.
Can't blame them for that.
Indeed. Although widely implemented, there has never been a public
specification on DOM Level 0, one has only the Netscape JavaScript
Reference and MSDN Library at hand for most features.
I might wanna sleep a bit more....


And you might want to validate your documents before complaining.
An `action' attribute value (even if empty) is missing for the
`form' element, too.

You also want to drop that "browser detection" nonsense, see for
example <http://pointedears.de/scripts/test/whatami>.
PointedEars
Oct 21 '05 #5

P: n/a
Thomas 'PointedEars' Lahn said the following on 10/21/2005 3:07 PM:
Jochem Donkers wrote:

Apprently, my javascript code was correct, but I made a basic mistake
in my HTML form. For Safari 2.0 it is sufficient that a <form
id="registration"> However, any other browser needs a name="'.

That's just not true. One can access `form' element objects by ID within
the `document.forms' collection in Mozilla Firefox, for example. That is
because the `name' attribute is not #REQUIRED for `form' elements in Valid
HTML 4/XHTML 1.x.

Your problem is instead that you are using proprietary referencing which
is likely to differ in support between user agents. Instead of

document.registration.priority1.value

use the standardized

document.forms['registration'].elements['priority1'].value

and everything should work smoothly even without `name' attributes.


Can you name a browser where
document.formName.elementName.property
doesn't work but
document.forms['formName'].elements['elementName'].property
does work?
Except in the case where the formName or elementName contain spaces, []
or other undesirable characters?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 21 '05 #6

P: n/a
> > (Microsoft can't even adhere to their own standards!)

I love this anti-MS shit. MS sticks to the same method, people complain
about it using old technology. They update and people complain about MS
not adhering to their own standards.


And I wouldn't complain about it if they updated so they were
compatable with a standard or another browser or the such, but all they
did was switch from one proprietary Active X component to another. This
is hardly progress on their part... two "standards" of Active X from
Micro$oft while every other browser uses the exact same XMLHttpRequest
object.

(At least I hear this will exist in IE7... I guess they're trying and I
do have to give them credit for that...)

Oct 22 '05 #7

P: n/a
Joshie Surber said the following on 10/22/2005 7:17 AM:
(Microsoft can't even adhere to their own standards!)
I love this anti-MS shit. MS sticks to the same method, people complain
about it using old technology. They update and people complain about MS
not adhering to their own standards.

And I wouldn't complain about it if they updated so they were
compatable with a standard or another browser or the such, but all they
did was switch from one proprietary Active X component to another.


And the new one seems to be better than the old one. And no, MS will
never get away from ActiveX.
This is hardly progress on their part... two "standards" of Active X from
Micro$oft while every other browser uses the exact same XMLHttpRequest
object.
No, they all use there own implementation of a native XMLHTTPRequest
object. And not "every other browser" implements it.
(At least I hear this will exist in IE7... I guess they're trying and I
do have to give them credit for that...)


That will have to wait until IE7 is finally released.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 23 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.