輸出的 「http://本地主機:6833/Service1.asmx的/的HelloWorld」:問題與jQuery和C#的Web服務從網絡服務,
<string xmlns="http://tempuri.org/">
[{"Name":"Pini","Age":"30","ID":"111"},{"Name":"Yaniv","Age":"31","ID":"Cohen"},{"Name":"Yoni","Age":"20","ID":"Biton"}]
</string>
HTML代碼:
<html>
<head>
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
type: "POST",
url: "Service1.asmx/HelloWorld",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
alert("Result: " + msg);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("Error: " + textStatus);
}
});
});
</script>
</head>
<body>
</body>
</html>
當我在瀏覽器中運行index.html我得到了錯誤警報..試了很多東西,但無法找出什麼缺失..
有什麼errorthrown? – 2012-07-18 11:14:09
唯一錯誤:錯誤。但不知道該功能是如何工作的,所有這個新的 – stianboe 2012-07-18 11:18:58
試試這個提醒(「Error:」+ errorThrown);並告訴我你得到了什麼。 – 2012-07-18 11:20:11