在我的应用程序中,我从sql存储过程获取一个值,我在我的ajax方法中获取该值。现在我想将该值传递给我的ajaxscript页面中的另一个方法。我想做什么。我试过了会话,但它不起作用。
if (str1.length > 0)
{
var BU = str1.split('|||')
for (var iCount = 0; iCount < $(sddlBusinessUnit).options.length; iCount++)
{
if ($(sddlBusinessUnit).options[iCount].value == Maincondetails[3])
{
$(sddlBusinessUnit).options[iCount].selected = true;
$(sddlSite).length = 0;
var siteID = Maincondetails[4];
//$_SESSION["Id"] = siteID;
if (($(sddlBusinessUnit)).selectedIndex > 0) {
displayLoadingImage(($(sddlBusinessUnit)));
var url = requestURL + '?mode=BU&BU=' + (($(sddlBusinessUnit))).options[($(sddlBusinessUnit)).selectedIndex].value; //Append the name to search for to the requestURL
xmlHttp = null;
xmlHttp = GetXmlHttpObject(SiteHandler);
xmlHttp_Get(xmlHttp, url); //Send the xmlHttp get to the specified url
getdata(siteID);
}
break;
}
}
}
在这个方法中,我在var siteID中存储了一个maincondetails [4]的值,在另一个方法中使用了这个siteID
function SiteHandler() {
if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete') {
hideLoadingImage();
var str = xmlHttp.responseText;
if (str != "") {
var Results = str.split('~~');
$(sddlSite).selectedIndex = -1;
$(shdnSiteID).value = '';
if (Results.length > 0) {
var Sites = Results[0].split('|||')
var Site;
$(sddlSite).length = Sites.length + 1;
$(sddlSite).options[0].value = 0;
$(sddlSite).options[0].text = '-- Select -';
for (i = 0; i < Sites.length; i++) {
Site = Sites[i].split('||');
$(sddlSite).options[i + 1].value = Site[0];
$(sddlSite).options[i + 1].text = Site[1];
// var data = HttpContext.Current.Session["Id"];
// if (Site.length > 0) {
// for (var iCount = 0; iCount < $(sddlSite).options.length; iCount++) {
// if ($(sddlSite).options[iCount].value == objthis) {
// $(sddlSite).options[iCount].selected = true;
// break;
//
// }
// }
// }
}