naoya.net@Wiki

Ajax+Webサービス

最終更新:

匿名ユーザー

- view
管理者のみ編集可

XMLHttpRequestオブジェクト生成

try {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
  xmlHttp=new XMLHttpRequest();
}

POST

xmlHttp.Open("POST","/AjaxTestXML/Service1.asmx/GetPIMITB","HTTP/1.1");

xmlHttp.SetRequestHeader("Host", "localhost");
xmlHttp.SetRequestHeader("Content-type", "application/x-www-form-urlencoded");

xmlHttp.SetRequestHeader("Content-Length", "5");
xmlHttp.send("orcd=949868&ybcd=" + document.fm.ybcd.value);

webサービスの戻り値がDataSetの場合

var aData =
xmlHttp.responseXML.selectSingleNode("DataSet/diffgr:diffgram/NewDataSet");

var data = aData.childNodes;
for (i =0; i < data.length; i++) {
  data[i].childNodes[0].firstChild.nodeValue
  data[i].childNodes[1].firstChild.nodeValue
}
目安箱バナー