Solved

ajax onreadystatechange parameter

Posted on 2009-07-07
1
399 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 75

Accepted Solution

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

0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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

626 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