【发布时间】:2014-09-16 21:57:50
【问题描述】:
我正在使用 CodeIgniter,我的 js 代码在我的“视图”中,我想在我的控制器中传递值。
var storage =[];
function something()
{
storage.push('the value');
}
现在我想要一种更好的方法将存储数组传递到我的 PHP 中。提前致谢。 此代码不起作用,因为它位于单独的文件夹中。
$.ajax({
url: 'yourPHPFile.php',
type: 'POST',
data: {data:storage.toString()},
success: function(result) {
// handle your success
},
error: function() {
// alert("error");
}
});
【问题讨论】:
-
您可以为此目的使用 JSON
-
您能否详细说明
"push storage array into my php"。它相当广泛和模糊。 -
我知道,但我不知道语法
-
不要介意推送..一切正常..唯一的问题是将数组传递给 php 文件
-
你想在php中如何使用它?您需要提供更多信息。
标签: javascript php html codeigniter