Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用JQuery打开新的php页面_Javascript_Php_Jquery_Mysql_Html Select - Fatal编程技术网

Javascript 使用JQuery打开新的php页面

Javascript 使用JQuery打开新的php页面,javascript,php,jquery,mysql,html-select,Javascript,Php,Jquery,Mysql,Html Select,每当用户使用JQuery单击我的一个html选择选项时,我想打开一个新页面。按照JQuery教程上的示例,我构建了代码,如下所示。但是,当我单击任何选项时,页面都不会打开 $('#Databases').change(function () { $.post("test.php"); }); 其中数据库是我的selectID。为什么我不能打开test.php?有解决办法吗 使用window.open功能: $('#Databases').change(function () {

每当用户使用JQuery单击我的一个html选择选项时,我想打开一个新页面。按照JQuery教程上的示例,我构建了代码,如下所示。但是,当我单击任何选项时,页面都不会打开

$('#Databases').change(function () {

    $.post("test.php");
});

其中
数据库
是我的selectID。为什么我不能打开
test.php
?有解决办法吗

使用window.open功能:

$('#Databases').change(function () {
    window.open("test.php");
});

因为
$.post
只是带有
type='post'
-异步调用的
$.ajax
。您可以在该函数的
done
success
部分打开新窗口,但我想这不是您想要的。

使用window.open函数:

$('#Databases').change(function () {
    window.open("test.php");
});

因为
$.post
只是带有
type='post'
-异步调用的
$.ajax
。您可以在该函数的
done
success
部分中打开新窗口,但我想这不是您想要的。

您应该使用
窗口。位置
窗口。打开

$('#Databases').change(function (e) {
        window.open("testScript.php"); // if you want to open another window
        // window.location.href = "testScript.php"; //if you want to open in same window
});

您应该使用
窗口.位置
窗口.打开

$('#Databases').change(function (e) {
        window.open("testScript.php"); // if you want to open another window
        // window.location.href = "testScript.php"; //if you want to open in same window
});
open()
方法打开一个新的浏览器窗口。 如果您想在同一浏览器窗口中打开新页面,我建议使用
window.location.assign()

例如:

$('#Databases').change(function () {
   window.location.assign("test.php");
});

方法打开一个新的浏览器窗口。 如果您想在同一浏览器窗口中打开新页面,我建议使用
window.location.assign()

例如:

$('#Databases').change(function () {
   window.location.assign("test.php");
});

$.post()
发出AJAX请求。如果要更改当前页面,则需要。
$.post()
发出AJAX请求。如果您想更改当前页面,您需要。感谢您的快速响应。感谢您的快速响应。