我正在使用 ajax 调用从 Web 服务获取数据。我将它保存在一个变量中,我面临的问题是我需要显示我正在进入选择菜单的这些数据..我无法破解它。我的html代码。
<div data-role="page" id="requestPage">
<div data-role="fieldcontain">
<select id="select-choice-3" name="pid you need">
<option value="select-value" selected="selected">-- Select PID --</option>
// here i want my data to be
</select>
</div>
</div>
JS代码
function content_Load(){
var soapMessage='<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetProjectByPeopleId xmlns="http://there.org/"><tmsUserId>' + TmsUserId +'</tmsUserId></GetProjectByPeopleId></soap:Body></soap:Envelope>'
$.ajax({
url: "http://22.232.32.14/therewebservice/thereeatmswebservice.asmx?op=GetProjectByPeopleId",
type: "POST",
dataType: "xml",
SOAPAction: "http://there.org/GetProjectByPeopleId",
data: soapMessage,
complete: endSaveProduct,
contentType: "text/xml; charset=\"utf-8\""
});
return false;
}
function endSaveProduct(xmlHttpRequest,status){
$(xmlHttpRequest.responseXML)
.find('Table')
.each(function()
{
var ProjectName =$(this).find('ProjectName').text();
// i am able to get ProjectName as my data, now i want it to get into the select menu for which i have written the code bellow but that's not working.
var optionlist='';
optionlist += '<option>' + ProjectName + '</option>';
$("#select-choice-3").html(optionlist).selectmenu('refresh', true);
window.location.href="#requestPage";
});
}