我正在使用以下代碼來檢測表單選擇中的更改,然後發送一個AJAX get請求與數據。AJAX獲取查詢不會導致頁面加載
$("#configset").change(function(){
$.ajax({
method: "get",
url: "/bmcfg/index.php", // This is the url that will be requested
data: {"configset": $("#configset").val(),
"configupdate": "update"
},
success:function()//we got the response
{
// alert('Successfully called:'+ $("#configset").val());
},
error:function(){alert('Exeption:');}
});
});
在服務器端,我使用PHP來處理請求。
if ((isset($_GET['configupdate']) and $_GET['configupdate'] == 'update'))
{
echo 'get received:'.$_GET['configupdate'];
include project.html.php
}
我從來沒有看到被打印在新頁面上回聲線?我只是希望PHP加載新的網頁,而不必將它作爲數據發送回ajax。
你希望在哪裏看到回波線「打印?」這將是從服務器返回的響應,所以您應該在JavaScript中的「成功」回調中看到該值。 – smarx
包含'project.html.php';在那個網頁上。它包括在回聲之後。 – marc
'成功:功能(響應){警報(響應);}'它說什麼?檢查 –