我无法使用jquery发送POST/Get请求。我有一个python Flask服务器设置。卷曲要求完美。我可以看到请求触发服务器,但这些Ajax请求不会触及服务器。以下是我一直在努力的代码。JQuery .ajax不发送请求
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(document).ready(function() {
$("#b1").click(function() {
$.ajax({
type: 'post',
url: 'http://np.mystiq.xyz/paste',
complete: function(response) {
$('#output').html(response.responseText);
},
error: function() {
$('#output').html('Bummer: there was an error!');
},
});
});
});
</script>
</head>
<body>
<button id="b1">test success </button>
<div id="output"/>
</body>
</html>
但这小提琴似乎工作http://jsfiddle.net/zc59uLnc/所以,问题是用jQuery。不知道究竟是什么问题。任何帮助深表感谢。
它是停留在跨域?如果您从同一个域名申请,该怎么办? 如果是跨域,请将'Access-Control-Allow-Origin'设置为'*' 请参阅http://stackoverflow.com/questions/3506208/jquery-ajax-cross-domain – vee