Javascript AJAX get查询未导致页面加载
我使用以下代码检测表单选择中的更改,然后发送一个包含数据的AJAX get请求Javascript AJAX get查询未导致页面加载,javascript,php,jquery,ajax,get,Javascript,Php,Jquery,Ajax,Get,我使用以下代码检测表单选择中的更改,然后发送一个包含数据的AJAX get请求 $("#configset").change(function(){ $.ajax({ method: "get", url: "/bmcfg/index.php", // This is the url that will be requested data: {"configset": $("#configset").v
$("#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。在函数中添加一个参数,从PHP获取值:
success:function( data )//we got the response
{
alert( data ); // <========== VALUE ECHOED FROM PHP.
}
success:function(data)//我们得到了响应
{
alert(data);//解决方案显然不是使用AJAX,而是使用表单并在检测到更改时提交表单。AJAX将在AJAX中发送和接收数据。因此,服务器端PHP脚本发送的数据也将发送到AJAX
这可以通过使用JQuery提交表单来解决
$("#selectid").change(function(){ <------ this is the select tag "id"
$("#formid").submit(); <---- this is the form tag "id"
});
$(“#selectid”).change(function(){您希望在哪里看到回显行“printed?”这将是从服务器返回的响应,因此您应该在JavaScript.include'project.html.php'中的success
回调中看到该值。它包含在回显之后。success:function(response){alert(response);}
它说了什么?选中“是”我将整个网页返回“响应”。我如何显示新网页?是的。我只想让PHP接收get请求并将页面发送到浏览器,而不是AJAXI希望PHP脚本运行。有没有办法让它这样做?因为脚本将加载一些新变量,我将将它们放在一个不同的页面中,脚本loads@amansehgal0u2,您正在使用ajax调用PHP,当PHP运行时,结果将返回到ajax。这就是它的工作方式。顺便说一句,PHP实际上正在运行,但您没有看到结果。是的,谢谢。我理解这一问题。我看到整个该死的网页现在都放在数据中。但这不是w我想要的是lol。我想我想要PHP脚本将网页发送到浏览器。我很惊讶,你的问题的答案是不可能的。Ajax不允许这样。