473,372 Members | 926 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,372 software developers and data experts.

Trying to pass a variable to xmlHttp.onreadystatechange

Hello,
I have this:
function process(a,b)
{
xmlHttp=GetXmlHttpObject();
//alert(xmlHttp)
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return
}
var url="http://www.xx.com/xxxxx/CheckEmailAddress.php"
url=url+"?Email="+a+"&Password="+b

xmlHttp.open("GET",url,true);
xmlHttp.send(null);
xmlHttp.onreadystatechange=stateChanged;
}

and I want to pass a and b to "stateChanged"

but its not working as:
xmlHttp.onreadystatechange=stateChanged(a,b); I'm getting a "type
mismatch"
Any Help?
Thanks
Mike
Oct 2 '08 #1
1 5088
Mike meinte:
Hello,
I have this:
function process(a,b)
{
xmlHttp=GetXmlHttpObject();
//alert(xmlHttp)
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request");
return
}
var url="http://www.xx.com/xxxxx/CheckEmailAddress.php"
url=url+"?Email="+a+"&Password="+b

xmlHttp.open("GET",url,true);
xmlHttp.send(null);
xmlHttp.onreadystatechange=stateChanged;
}

and I want to pass a and b to "stateChanged"

but its not working as:
xmlHttp.onreadystatechange=stateChanged(a,b); I'm getting a "type
mismatch"
Because stateChanged() returns something else than a function.

You need something like
xmlHttp.onreadystatechange=function(a,b) {
return function() {
// have a and b available
};
}(a, b);

But this has been discussed here frequently.

Gregor
--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Oct 2 '08 #2

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

Similar topics

4
by: Wayne Wengert | last post by:
I found a code sample that allows you to use a 5 digit zip code to lookup the correct city and state using a Web Service (ASP.NET). When I run the javascript code (see below) on my aspx page...
20
by: chris.schwalm | last post by:
This is part II of this <a...
3
by: Andrewh | last post by:
Hi, I am having a bit of a problem with using xmlhttp. The code of the javascript file is shown below used in Windows XP. var xmlhttp = null; function SetURLDiv(url) { if...
7
vikas251074
by: vikas251074 | last post by:
Can I assign value to cookies immediately after selecting a value from list? <select name="vlan_name" style="width:150px "> <%set rs = conn.execute("select vlan_name from vlan_master order by...
3
by: VK | last post by:
On Apr 21, 1:54 pm, joe <m...@invalid.comwrote: http://www.jibbering.com/faq/index.html#FAQ4_18
7
by: renphi | last post by:
I'm attempting display a DIV when clicking on a list item. This works, but only for the first list item. I realized that this was due to the ID not being unique so I made the IDs unique. My...
2
by: trpost | last post by:
Is it possible to execute javascript as passed in xmlHttp.responseText Here is what I am doing: search.js var xmlHttp xmlHttp=GetXmlHttpObject() var url="search.php"...
12
by: sarega | last post by:
Hi, <? #cd.php echo "<input type='text' name='text1' id='text1' onchange=\"return_value()"\ /><br></br>"; ?> Javascript file var xmlHttp; function return_value() { var...
1
by: kkshansid | last post by:
i want to pass both variables($q1 and value of select) from this php page to java script so that i can get both variables in second php file srt.php <script type="text/javascript"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.