Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ajax onreadystatechange parameter

Posted on 2009-07-07
1
Medium Priority
?
405 Views
Last Modified: 2012-08-14
I want to pass a parameter to the callback function to identify one ajax call from another.  
This code is not doing the business.  Is it possible?  How is it done?
function runscript(page, data, element)
{
	//get ajax object
	HTTPrequest[req_no]=GetHTTPrequestObject();
	// set callback
	HTTPrequest[req_no].onreadystatechange=stateChanged(req_no);
	//check there is a connection to server
	if (HTTPrequest[req_no]==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	
	info['ajax'] += 1;
	info['script'] = page;
	
	//create script url
	var url=page+".php";
	url=url+"?element="+element;
	for(i in data)
	{
		url=url+"&"+i+"="+data[i];
	}
	url=url+"&sid="+Math.random();
 
	//load the script
	HTTPrequest[req_no].open("GET",url,true);
	HTTPrequest[req_no].send(null);
}

Open in new window

0
Comment
Question by:Koakuma
1 Comment
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 total points
ID: 24794283
HTTPrequest[req_no].onreadystatechange=new function () { stateChanged(req_no) }

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question