【发布时间】:2014-05-06 07:15:44
【问题描述】:
我正在使用 ajax 来制作寻呼机。 我正在通过 url 页面传递“pag”变量。
//Initialise the table at the first run
$( '#content' ).load( "paginator.php?pag=1", function()
{
hide_anim();
});
//Page navigation Click
$( document ).on( 'click', 'li.goto', function()
{
//Get the id of clicked li
var pageNum = $(this ).attr('id');
//Loading Data
$( "#content" ).load( "paginator.php?pag=" + pageNum, function()
{
hide_anim();
});
});
现在我还想传递一个包含数组的变量。你能做到吗?
我的数组
$src = array (’name’ => ‘foo’, ‘sname’ => ‘’, age => '22');
否则我可以使用 post 做同样的事情(加载)?我怎么能那样做?谢谢
编辑
我是这样做的。
//Loading Data
$( "#content" ).load( "paginator.php", { pag: pageNum, phparr=?? }, function()
{
hide_anim();
});
现在,如何从 php 获取数组并将其作为 jquery 变量 (phparr) 传递?谢谢
【问题讨论】:
-
查看 JSON Stringify 并使用对象而不是数组。然后在服务器端解码 JSON。 stackoverflow.com/questions/16196338/…