jQuery呼叫Web Service
對jQuery來說,這是最基本不過的事情了....
PO在這裡的用處是可以直接可以讓我Copy程式碼XD
省掉去官網尋找的時間= =+
以下是用Post呼叫....
//jQuery 呼叫Web service by POST
//1.使用 ajax物件
$.ajax({
type: 'post',
url: "../webService/helow.asmx/helow",
//要傳過去的值
data:'name=' + 變數1 + '&Text=' + 變數2,
//成功接收的function
success: function(oXml) {
//先將xml轉成jQuery物件
var x = $(oXml);
//用find和text來做擷取
alert(x.find("string").text());
},
error: function() { alert('ajax failed'); }
});
//2.用post物件呼叫
$.post("../webService/helow.asmx/sendHTMLMail",
{ name:變數1, text:變數2 },
function(data)
{
var x = $(data);
alert(x.find("string").text());
},"xml"
);