我使用下面的代码检测表单选择中的更改,然后用数据发送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。
发布于 2016-06-30 21:01:21
解决方案显然不是使用AJAX,而是使用表单并在检测更改时提交表单。AJAX将在AJAX中发送和接收数据。因此,服务器端PHP脚本发送的数据也将发送到AJAX。
可以通过使用JQuery使用表单提交来解决这个问题。
$("#selectid").change(function(){ <------ this is the select tag "id"
$("#formid").submit(); <---- this is the form tag "id"
});发布于 2016-06-30 20:15:08
向从PHP获取值的函数中添加一个参数:
success:function( data )//we got the response
{
alert( data ); // <========== VALUE ECHOED FROM PHP.
}https://stackoverflow.com/questions/38132391
复制相似问题