demo.html
1023 Bytes
<h4>点击下列链接-发送ajax请求</h4>
<a href="javascript:;" onclick="test()">发送ajax请求-基础</a>
<a href="javascript:;" onclick="test2()">发送ajax请求-带参数</a>
<a href="javascript:;" onclick="test3()">发送ajax请求-同步请求</a>
<style>
h4 { margin: 10px; }
a {
display: block;
padding: 5px 16px;
color: #108ee9;
text-decoration: underline;
}
</style>
<script>
function test() {
Mobile_NS.ajax("/mobilemode/mobile/demo/api/ajax/data.json", function(responseText){
alert("响应结果:" + responseText);
});
}
function test2() {
Mobile_NS.ajax("/mobilemode/mobile/demo/api/ajax/data.json", {a:"1", b:"2"}, function(responseText){
alert("响应结果:" + responseText);
});
}
function test3() {
Mobile_NS.ajax("/mobilemode/mobile/demo/api/ajax/data.json", function(responseText){
alert("响应结果:" + responseText);
}, {async:false});
alert("发送同步请求时会等待ajax执行完成后再执行到这里");
}
</script>