有谁知道一个好的级联/链式选择jquery 1.4.x插件(或jquery ui小部件),它使用ajax调用php,返回json格式的数据来填充选项?
发布于 2010-11-08 01:04:46
这个问题很模糊,但是您可以使用.post()函数将请求发送到PHP文件,然后让PHP创建一个数组,并使用json_encode()将该数组编码为JSON,然后回显该JSON数据,该数据可由jQuery .post()接收。这样做:
jQuery:
$.post("you_php_file.php",{ request: "YOUR_REQUEST" },function(data){
//do something with the data, stored with the variable data
$('ul li:nth-child(1)').html(data[0]);
$('ul li:nth-child(2)').html(data[1]);
},"json")PHP:
$request = $_POST['request'];
//create an array with the data you want to send to JavaScript
$array = array();
$array[] = 'Hello';
$array[] = 'World!';
echo json_encode($array);https://stackoverflow.com/questions/4116466
复制相似问题