从PHP函数返回的jQuery数组 [英] Returning an array from a PHP function to jQuery
本文介绍了从PHP函数返回的jQuery数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个PHP函数,返回的数组。什么是接收这个使用jQuery的最佳方法是什么?
I have a PHP function that returns an array. What is the best way to "receive" this using jQuery?
推荐答案
使用的 json_en code()把你的PHP数组到一个本地JavaScript数组,然后使用jQuery的 $。帖子, $不用彷徨或< A HREF =http://docs.jquery.com/Ajax/jQuery.ajax相对=nofollow> $。阿贾克斯的方法来从你的PHP脚本这个值。我一般使用$。员额,除非我需要的特殊功能,$就提供了。
Use json_encode() to turn your PHP array into a native JavaScript array, then use jQuery $.post, $.get, or $.ajax methods to fetch this value from your PHP script. I generally use $.post unless I need the special features that $.ajax provides.
这篇关于从PHP函数返回的jQuery数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文