求救!jquery post传值并跳转页面出错

yang7lang 2014-03-07 03:15:19

$.post(
'2list_confirm.php',
{data_send:cart_send},
function(data){
document.write(data);
//window.location.href ="2list_confirm.php";
});

这是我的post函数,现在的问题是我用document.write(data);载入页面2list_confirm.php时载入的页面css正常,但是js没有调用,而用window.location.href ="2list_confirm.php";时$data_get=$_POST['data_send']传值又接受不到,求救啊
就是把变量cart_send里面的字符串传到2list_confirm.php然后跳转到2list_confirm.php去
...全文
233 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yang7lang 2014-03-08
  • 打赏
  • 举报
回复
引用 3 楼 crab890715 的回复:
window.location.href ="2list_confirm.php?data_send="+cart_send;此种方式是属于get请求, 然后使用$data_get=$_GET['data_send']去取吧,注意到底是get请求还是post请求, 如果使用表单提交根据表单中的method判断是get还是post,$.post这个是post请求,$.ajax这个也需要在里面设置post还是get请求,我对PHP不是很了解,我想$_POST应该是取post的参数吧,那么肯定就存在$_GET这个变量,而这个变量就是去get请求的参数吧
成功了,谢谢侬
yang7lang 2014-03-08
  • 打赏
  • 举报
回复
引用 1 楼 microlab2009 的回复:
这个不需要用异步啊 直接链接跳转就行了啊window.location.href ="2list_confirm.php?data_send="+cart_send; 干嘛多此一举呢
的确是这样子
螃蟹哥哥 2014-03-07
  • 打赏
  • 举报
回复
window.location.href ="2list_confirm.php?data_send="+cart_send;此种方式是属于get请求, 然后使用$data_get=$_GET['data_send']去取吧,注意到底是get请求还是post请求, 如果使用表单提交根据表单中的method判断是get还是post,$.post这个是post请求,$.ajax这个也需要在里面设置post还是get请求,我对PHP不是很了解,我想$_POST应该是取post的参数吧,那么肯定就存在$_GET这个变量,而这个变量就是去get请求的参数吧
tony4geek 2014-03-07
  • 打赏
  • 举报
回复
2个url 都一样,你直接请求。
嘻哈大咖秀 2014-03-07
  • 打赏
  • 举报
回复
这个不需要用异步啊 直接链接跳转就行了啊window.location.href ="2list_confirm.php?data_send="+cart_send; 干嘛多此一举呢

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧