All pastes #1077666 Raw Edit

AJAXscripts

public javascript v1 · immutable
#1077666 ·published 2008-07-20 17:50 UTC
rendered paste body
// JScript source codevar xmlHttp// So this function works, it will display the proper stuff when I click the headers, but...function showParameters(str){ xmlHttp=GetXmlHttpObject();if (xmlHttp==null)  {  alert ("Your browser does not support AJAX!");  return;  } var url="parameters.asp";url=url+"?q="+str;xmlHttp.onreadystatechange=stateChanged;xmlHttp.open("GET",url,true);xmlHttp.send(null);}// This one doesn't. Everything is pretty much exactly the same except it passes a couple arguments so the page knows// which genre was picked and also which drop-down box was used.function populateGenres(str){xmlHttp=GetXmlHttpObject();if (xmlHttp==null)	{	alert ("Your browser dows not support AJAX!");	return;	}var url="genres.asp"url=url+"?q=" + which + "&g=" + genre;xmlHttp.onreadystatechange=genreChanged(which);xmlHttp.open("GET",url,true);xmlHttp.send(null);}function stateChanged() { if (xmlHttp.readyState==4){ document.getElementById("params").innerHTML=xmlHttp.responseText;}}// I want it to be so that when I pick a genre from the first drop-down box it will find all the movies// with that genre, get the other genres of those movies, then put them is the second box. Then when you// pick one from the second box it does the same for the third one. This function /should/ make those// drop-down boxes appear but it doesn't seem to be working.function genreChanged(which){	if (xmlHttp.readyState==4)	{		switch(which)		{		case "genreSelect1":			document.getElementById("genrespot2").innerHTML=xmlHttp.responseText;			break;		case "genreSelect2":			document.getElementById("genrespot3").innerHTML=xmlHttp.responseText;			break;		}					}}function GetXmlHttpObject(){var 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;}