检索 JSON 对象时,我收到以下错误:
- SyntaxError:Mozilla 中的标签无效。
- Uncaught SyntaxError: Unexpected token : in Chrome
我的 JSON 对象是如下所示的格式:
{
"userName" : "clevermeal835",
"userRole" : "Participant",
"userAccountStatus" : "Active"
}
代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="Scripts/jquery-min.js"></script>
<script src="Scripts/jquery_validate.js"></script>
<script>
$(document).ready(function() {
loadLatestTweet();
});
function loadLatestTweet(){
var xhr = new XMLHttpRequest();
var uid = "clevermeal835";
var pwd = "Welcome_1";
var userType = "participant";
var surl = 'http://localhost:8080/RESTlet_WS/MobiSignIn/{"userName":"'+uid+'","password":"'+pwd+ '","userType":"'+userType+'"}&callback=?';
var jqxhr = $.getJSON(surl, function() {
alert("success");
}).success(function() { alert("second success"); }).error(function() { alert("error"); }).complete(function() { alert("complete"); });
jqxhr.complete(function(){ alert("second complete"); });
}
</script>
</head>
<body>
<input id="jsonpbtn2" type="submit" value="button" />
</body>
</html>