我正在使用以下代码来检测表单选择中的更改,然后发送一个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
'成功:功能(响应){警报(响应);}'它说什么?检查 –