0
我使用html和jQuery代码开发了一个简单的网页,它将使用http post将数据传递到我的网关。来自服务器的响应是json对象,{“remarks”:“成功”}。然而,我的网页始终未能得到相关回应JSON POST未能获得响应数据
下面是我的网页代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Loading data into a PhoneGap ap2p</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="jquery.jsonp.js"></script>
</head>
<body>
<ul id="your-tweets"></ul>
</body>
<script>
$(document).ready(function(){
$.ajax({
type: 'POST',
url: 'http://localhost:8091/gateway/jjh/v1.0/login?userid=ccc&password=pwd',
crossDomain: true,
data: 'userid=wcc',
dataType: 'json',
success: function(responseData, textStatus, jqXHR) {
alert("Success>>");
var obj = responseData;
alert(obj.remarks);
},
error: function (responseData, textStatus, errorThrown) {
alert('POST failed.');
}
});
});
</script>
</html>
谁能帮助/建议我对此有何看法?
你的脚本是否在'http:// localhost:8091 /'上运行? – 2012-08-02 14:57:32
您是否尝试过使用Firefox/Firebug查看HTTP响应? – Steve 2012-08-02 15:11:40