jquery, ajax, php, json - is there a good cascade/chained select plugin for jquery?
Does anyone know for a good cascade/chained select 开发者_JS百科jquery 1.4.x plugin(s) (or jquery ui widget) that uses ajax call to php that returns json format data for populating options?
This question is vague, but you can use the .post() function to post requests to a PHP file and then have the PHP create an array and use json_encode()
to encode the array into JSON and then echo that JSON data, which can be received by the jQuery .post(). Do something like this:
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);
精彩评论