0
我剛剛進入ajax,我不明白代碼有什麼問題?Ajax沒有得到結果
的index.html
<html>
<head>
<title>Ajax call</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
<head>
<body>
<script>
var UserID = 'myname';
var EmailAddress = '[email protected]';
$.ajax({
url: "ajax.php",
type: "get", //send it through get method
data:
{
ajaxid: 4,
UserID: UserID,
EmailAddress: EmailAddress
},
success: function(response)
{
//Do Something
Alert("Sucess");
},
error: function(xhr)
{
//Do Something to handle error
Alert("Failure");
}
});
</script>
</body>
</html>
ajax.php
<?php
foreach ($_GET as $key => $value) {
echo $key . ' => ' . $value . '<br />';
}
?>
解決這個問題後,我的主要目標是與連接功能,以取代在php文件中的代碼到SQL Server並使用ajax調用發送的數據檢索一些數據。 我會稍後再試。
問候, 埃利奧·費爾南德斯
巴特,成功消息現在顯示。爲什麼在php文件中沒有GET全局arry的回顯? –
我剛編輯我的答案。立即嘗試 – Bart
謝謝,它的工作。 :-) –