我有来自REST Web服务的JSON响应,并希望使用jQuery将该数据绑定到html。看起来它甚至没有点击我在jquery中提供的web服务URL。 Url工作正常,它在浏览器中提供了JSON数据,但我使用的jQuery无法从中获取任何内容。我在这里粘贴我的代码,如果有人可以提供帮助,请告诉我。 调试脚本时,它直接在ajax调用的错误部分。
<script type="text/javascript">
$(document).ready(function () {
GetData();
});
function GetData() {
// alert(textblock.value);
$.ajax({
type: "GET",
url: "http://localhost:8092/api/Employees",
data: "{'employeeId'= '" + 1234 + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
var results = $.parseJSON(msg.d);
alert(msg);
alert(results);
},
error: function (result) {
alert('here');
var tt = result.text;
alert(tt);
}
});
}
</script>
答案 0 :(得分:0)
最后我能够立即获取数据。 我在$ .ajax中添加了以下属性:
processData:false, async:false,