I have the following javascripts which is working in IE, but not working in Firefox and opera. - var xmlhttp=null;
-
function showCustomer(str)
-
{
-
xmlhttp=getxmlhttp();
-
-
if (xmlhttp==null)
-
{
-
alert("Your Browser does not support AJAX");
-
return;
-
}
-
-
var url="search.php";
-
url=url+"?q="+str;
-
url=url+"&sid="+Math.random();
-
xmlhttp.onreadyStateChange=statechanged;
-
xmlhttp.open('get',url,false);
-
xmlhttp.send(null);
-
-
-
}
-
-
function statechanged()
-
{
-
alert("ok");
-
if (xmlhttp.readyState==4)
-
{
-
-
document.getElementById("txt").innerHTML=xmlhttp.responseText;
-
-
}
-
-
}
-
-
function getxmlhttp()
-
{
-
xmlhttp=null;
-
try
-
{
-
// Firefox, Opera 8.0+, Safari
-
xmlHttp=new XMLHttpRequest();
-
}
-
catch (e)
-
{
-
// Internet Explorer
-
try
-
{
-
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
-
}
-
catch (e)
-
{
-
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
}
-
return xmlHttp;
-
}
How to solve this problem.
Thanks in advance
8 9434 acoder 16,027
Recognized Expert Moderator MVP
Welcome to TSDN.
The probable reason why it is not working is that the global variable is "xmlhttp", but when using the XMLHttpRequest object, you have used "xmlHttp" (note the case difference).
Welcome to TSDN.
The probable reason why it is not working is that the global variable is "xmlhttp", but when using the XMLHttpRequest object, you have used "xmlHttp" (note the case difference).
Thanks for the response.
I have changed all varables as "xmlhttp". But still above problem exists. ie It is working in IE and not in firefox and opera.
acoder 16,027
Recognized Expert Moderator MVP
Perhaps onreadyStateCha nge should be onreadystatecha nge.
What error do you get? Check the console for errors or Firebug if you have it.
Perhaps onreadyStateCha nge should be onreadystatecha nge.
What error do you get? Check the console for errors or Firebug if you have it.
Thanks a lot
My code is working in firefox as well as in opera. I have changed onreadyStateCha nge to onreadystatecha nge .Then it is working in Opera, but not in firefox. . After this , I changed xmlhttp.open('G ET',url,false) to xmlhttp.open('G ET',url,true) .Now it is working IE, Opera and Firefox.
acoder 16,027
Recognized Expert Moderator MVP
Thanks a lot
My code is working in firefox as well as in opera. I have changed onreadyStateCha nge to onreadystatecha nge .Then it is working in Opera, but not in firefox. . After this , I changed xmlhttp.open('G ET',url,false) to xmlhttp.open('G ET',url,true) .Now it is working IE, Opera and Firefox.
It's good that you got it working, but how did it work in the other browsers with those mistakes. That last argument makes AJAX asynchronous.
I have the following javascripts which is working in IE, but not working in Firefox and opera.
var xmlhttp=null;
function showCustomer(st r)
{
xmlhttp=getxmlh ttp();
if (xmlhttp==null)
{
alert("Your Browser does not support AJAX");
return;
}
var url="search.php ";
url=url+"?q="+s tr;
url=url+"&sid=" +Math.random();
xmlhttp.onready StateChange=sta techanged;
xmlhttp.open('g et',url,false);
xmlhttp.send(nu ll);
}
function statechanged()
{
alert("ok");
if (xmlhttp.readyS tate==4)
{
document.getEle mentById("txt") .innerHTML=xmlh ttp.responseTex t;
}
}
function getxmlhttp()
{
xmlhttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest( );
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject(" Msxml2.XMLHTTP" );
}
catch (e)
{
xmlHttp=new ActiveXObject(" Microsoft.XMLHT TP");
}
}
return xmlHttp;
}
How to solve this problem.
Thanks in advance
*************** *************** ***
xmlhttp.open('g et',url,false);
Replace with
xmlhttp.open('g et',url,true);
acoder 16,027
Recognized Expert Moderator MVP
Hi, welcome to TSDN! Thanks for posting.
*************** *************** ***
xmlhttp.open('g et',url,false);
Replace with
xmlhttp.open('g et',url,true);
benoypaul managed to solve this, but thanks anyway for pointing out the change required.
...I changed xmlhttp.open('G ET',url,false) to xmlhttp.open('G ET',url,true) .Now it is working IE, Opera and Firefox.
Thank you for the info! Was having the same issue and this resolved it for me as well.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Arjen |
last post by:
Hi,
I want to reload 2 divs at one click. Ive tried:
<a href = "javascript:void(0);"
onclick="show('ajaxrequest.php?action=removefield','div1');show('ajaxrequest.php?action=reloaddiv2','div2')">verwijderen</a>
While both seperate actions work they dont when I put them together.
Anyone know how to fix this ?
My ajax.js with funcition show
|
by: Heofz |
last post by:
Hey all,
I've been banging my head against a brick wall on this one for the last 12 hours, and the time has come for me to give up and consult the gurus on this one.
The below URL contains a login page, you can test it using the details
User: marco
Pass: polo
This seems to work PERFECTLY in opera, and it works in firefox but ONLY if I have firebug enabled. I don't care about IE for now, I'll sort that out later.
|
by: henryrhenryr |
last post by:
I'm trying to log all links clicked. I'm just working this out so there may be some astoundingly bad methods. Please point out!
It all works nicely though if I use mouseover events as the trigger. If I use click events then the AJAX bit breaks.
Here's the code (mostly):
Adding event listener to all links (firefox tells me errors but it works?!). When I switch from mouseover to click, the whole thing breaks down.
function...
|
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 i change something in php file using in ajax function.it not refreshed,means its shows the previous result it not get updated.i can't understand whats the prob.this is the code i m using:
<?
include("config.inc.php");
//error_reporting(0); ...
|
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' the page with the results that have been retrieved thus far. This 2nd call loops until the first call (the search) is complete.
Everything works fine in Firefox, but in IE, the 2nd call doesn't work until the very end when the 1st call is complete....
| |
by: theS70RM |
last post by:
hi guys,
My code suddenly stopped working
here it is:
function Ajax(page,data){
page = "includes/" + page;
|
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 use it in sync mode. Any ideas what can I do?
Thanks,
Zalek.
|
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 Database but I'm stuck in the EDIT. I'm getting 2 problems over here. Below is the description:
1)The FIRST page will list all the records from the table which Admin can EDIT with CHECKBOX for each record to select. He can select one or more than one...
|
by: mike57 |
last post by:
The minimal AJAX script below works in Firefox, but not in IE, Opera, or Chrome. I could use some suggestions or referrals to resources that will help me get the script working in other browsers.
Before there are six characters entered in the CAPTCHA code field, the 'Send' button is supposed to be disabled. When there are at least six characters in the CAPTCHA code field, the script attempts to verify the CAPTCHA w/AJAX. If it verifies, it...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |