【发布时间】:2015-08-13 07:19:37
【问题描述】:
CodeIgniter:如何在新控制器中检索通过window.location.href 传递的ajax jquery 数据?
$(".x").on("click","a.p",function(){
productId = $(this).attr("productId");
alert("product ID : " + productId);
$.ajax({
url: 'home/allProductDetails',
type: 'POST',
data: {
'productId' : productId
},
success: function (dat) {
var result = eval('(' + dat + ')');
if (result.success == true)
{
if(result.data.length>0)
{//alert("Success");window.location.href = "newControllerName" + "?result=" + result.data;
}
}
在 ajax 成功时,使用 window.location.href 将数据传递给新控制器
【问题讨论】:
-
如何在 PHP 中使用。
$_GET['result'] -
我想你当你想要检索/获取数据时总是使用 GET 方法
-
谢谢纳伦德拉和奥尔德林27
-
如何拆分通过 $_GET['result'] 检索到的数组数据
-
在检索数组数据时,得到的结果为 x,y,z,a,b,c,l,m,n 而不是 x,y,z(第一个数组); a,b,c(第二个数组)和 l,m,n(第三个数组)
标签: php jquery ajax codeigniter controller