Passing parameters to AJAX Response function

how to pass paraemters to AJAX functions in IE, the code is working fi

Page 1 of 1

1 Replies - 5690 Views - Last Post: 30 January 2009 - 05:43 AM

#1 ajay.embed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-January 09

Passing parameters to AJAX Response function

Posted 30 January 2009 - 04:53 AM

function refreshWindow ()
{
	if (xmlHTTP)
		xmlHTTP = null;

	xmlHTTP = GetXmlHttpObject (responseRefreshWindow);
	var reqString;
	reqString = "url";
	xmlHTTP.open ("get", reqString, true);
	xmlHTTP.winid = "A1"; // Here IE browsr displays error, Firefox is Ok
	xmlHTTP.send (null);
	return false;
}

function responseRefreshWindow()
{
	if ((this.readyState == 4) || (this.readyState == "complete"))
	{ 
		var res = this.responseText;
		alert (this.winid);
	}
}


Is This A Good Question/Topic? 0
  • +

Replies To: Passing parameters to AJAX Response function

#2 thehat  Icon User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: Passing parameters to AJAX Response function

Posted 30 January 2009 - 05:43 AM

The way I've done this in the past is to append whatever variables you want to send to php to the the url that you pass through xmlHttp.open.

This is working code for a language selector I have, it should show you what I mean:
function changeLang(lang) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
		alert("Browser does not support HTTP Request");
		return;
	}
	var url="../scripts/changeLang.php";
	url=url+"?l="+lang;
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
	
function stateChanged() {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {	
		if(xmlHttp.responseText != '0') {
			window.location.reload();
		}	
	}
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1