我無法使用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