Home  >  Article  >  Backend Development  >  $_GET方法得不到url值

$_GET方法得不到url值

WBOY
WBOYOriginal
2016-06-20 12:29:381000browse

我的代码是这样的

jq中
$('#add_user').ajaxSubmit({
url:ThinkPHP['MODULE']+'/User/add',
type:'POST',
success:function(data){
alert(data);
var top=(screen.height-500)/2;
var left=(screen.width-500)/2;
window.open("http://localhost/yemian/Admin/Photo?id="+data+"",'111','height=620,width=500,top='+top+',left='+left+',toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');  
},
});


新打开的页面网址:http://localhost/yemian/admin/photo?id=31
新打开的页面中
echo $id=$_GET['id'];

但是获取不到$_GET['id'];


回复讨论(解决方案)

type:' POST',
你指定的是 post 方式,$_GET 当然取不到

type:'POST',

你用的是POST方式,
应该使用echo $id=$_POST['id']; 来获取

或者把jquery的
type:'POST',
改为
type:'GET',

type:' POST',
你指定的是 post 方式,$_GET 当然取不到


楼主是先post,post返回之后,再跳转到新的页面的。

楼主自己检查下,值是否传递过去

success:function(data){
alert(data);
看看data有什么。

前面几位都误导了,URL上的get跟ajax的POST和get没关系。
你要检查一下真实访问的URL,是不是带参数过去了,如果是,再检查是不是被URL重写处理了。

http://localhost/yemian/admin/photo?id=31

这样写没错
然后print_r($_GET);
看看有什么

http://localhost/yemian/Admin/Photo
http://localhost/yemian/admin/photo?id=31

有大小写之分,这两个是同一个页面吗?检查一下你改对文件了吗

哎哟我去,犯了个超低级错误

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn