Jquery - 无法从服务器提供数据 [英] Jquery - not being able to bring data from server
本文介绍了Jquery - 无法从服务器提供数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function () {
$("button").click(function(){
//$.post("http://localhost/api/ajax.asp", //This is working
$.post("http://zequet.somee.com/ajax.asp", // This is not working
{
name: "100"
},
function(data,status){
console.log(data);
document.getElementById("change").innerHTML = data;
if (data.success) {
alert("STATUS: " + status);
}
else {
alert("STATUS: " + status);
}
});
});
});
</script>
</head>
<body>
Ticket: <span id="change"></span><br />
<button>Test</button>
</body>
</html>
And this is the ajax.asp code
<%
Dim fname
fname = Request.Form("name")
fname = fname + 1
Response.Write(fname)
%>
我尝试了什么:
使用$ .post时工作正常(http:// localhost / api / ajax.asp
但是当从我的本地计算机执行时使用$ .post(http://zequet.somee.com/ajax.asp时它不起作用。
What I have tried:
It works fine when using $.post("http://localhost/api/ajax.asp"
but it doesn't work when using $.post("http://zequet.somee.com/ajax.asp" when executing from my local computer.
推荐答案
( document )。ready( function (){
(document).ready(function () {
( button)。 click( function (){
//
("button").click(function(){ //
.post(http://localhost/api/ajax.asp,//这是有效的
.post("http://localhost/api/ajax.asp", //This is working
这篇关于Jquery - 无法从服务器提供数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文