Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Onblur not working in mozilla, fine in IE

Reply
Thread Tools

Onblur not working in mozilla, fine in IE

 
 
rjones326@gmail.com
Guest
Posts: n/a
 
      01-15-2007
Hi,

I'm stupendously mystified by this strange activity. I cannot for the
life of me figure out why this will not work in mozilla. I've spent
hours mucking around with it. The php file is just an echo statement
now to simplify for the moment. If instead of calling the replace
function I've also tried putting in an alert function. Alert works,
the calling the php file does not.

Any suggestions greatly appreciated, I've never encountered such
difficult functionality as with javascript in firefox compared to IE.
Might just be my luck though...



<html>
<head>
<script language="javascript" type="text/javascript">
var url = "poo.php?pc=" ;


function aHttpResponse() {
if (http.readystate == 4) {
results = http.responseText ;
document.getElementById('state').value=http.respon seText ;
}

}
function fiction(){
alert("yes") ;
}
function callPHPResponse() {
var pcode = document.getElementById("postcode").value ;
http.open("GET",url+escape(pcode),true) ;
http.onreadystatechange = aHttpResponse ;
http.send(null) ;
}


function getHTTPObject() {
if (window.XMLHttpRequest) { // Mozilla, Safari, ...
http_request = new XMLHttpRequest();
} else if (window.ActiveXObject) { // IE
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
return http_request ;
}
var http = getHTTPObject() ;

</script>

</head>
<form action="post">
<table width="800">
<td width="100">Postcode</td>
<td width="700"><input type="text" name="postcode" id="postcode"
size="5" onblur="callPHPResponse();"></td>
</tr>
<tr>
<td width="100">State</td>
<td width="700"><input type="text" name="state" id="state"
size="50"></td>
</tr>
<tr>

</table>
</form>
</html>

 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      01-15-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) a écrit :
> Hi,
>
> I'm stupendously mystified by this strange activity. I cannot for the
> life of me figure out why this will not work in mozilla. I've spent
> hours mucking around with it. The php file is just an echo statement
> now to simplify for the moment. If instead of calling the replace
> function I've also tried putting in an alert function. Alert works,
> the calling the php file does not.
>
> Any suggestions greatly appreciated, I've never encountered such
> difficult functionality as with javascript in firefox compared to IE.
> Might just be my luck though...


what about :

function callPHPResponse() {
http = getHTTPObject(); // a new XHR isn't necessary on each call ?
var pcode =
... etc ...
}


Does code returned by php is understood ?

XMLHttp Object :

function getHTTPObject() {
var http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
// http_request.overrideMimeType('text/html');
}
}
else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
if (!http_request) {
alert('Impossible to create XMLHTTP instance');
return false;
}
return http_request;
}


Response comes back ?

function aHttpResponse() {
if (http.readystate == 4) {
results = http.responseText ;
alert('result = '+result);
document.getElementById('state').value = result;
}

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      01-15-2007
ASM a écrit :
>
> Response comes back ?
>
> function aHttpResponse() {
> if (http.readystate == 4) {


function aHttpResponse() {
if (http.readystate == 4) {
results = http.responseText ;
alert('result = '+results);
document.getElementById('state').value = results;
}
}

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
 
Reply With Quote
 
rjones326@gmail.com
Guest
Posts: n/a
 
      01-16-2007
Believe it or not that whole time it was because of

if (http.readystate == 4)

rather than

if (http.readyState == 4)

Works with the lowercase in IE.. does not in mozilla. I went back
through my numerous revisions of this code changing that and every time
the code worked straight away.

What a collosal waste of time. Lucky its paid time


ASM wrote:

> ASM a écrit :
> >
> > Response comes back ?
> >
> > function aHttpResponse() {
> > if (http.readystate == 4) {

>
> function aHttpResponse() {
> if (http.readystate == 4) {
> results = http.responseText ;
> alert('result = '+results);
> document.getElementById('state').value = results;
> }
> }
>
> --
> Stephane Moriaux et son (moins) vieux Mac déjà dépassé
> Stephane Moriaux and his (less) old Mac already out of date


 
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
Div with zindex=100 working fine under Firefox but not IE winstontuck@gmail.com HTML 0 08-15-2006 03:30 PM
onBlur validation not calling properly when press enterkey(not mouse click) raj ASP .Net 3 11-12-2005 06:31 AM
OnBlur not working ! EviL KerneL Javascript 5 09-30-2004 09:43 AM
boutique and fine art royalty free images - free fine art image offer Andrew Mowat Digital Photography 0 09-14-2004 05:35 AM
Program not Stripping Headers from Email though Working fine dont bother Python 1 03-04-2004 08:27 PM



Advertisments