Reputation: 143
So i want to send a variable to my php page and output appropriate json there based on the data. THis is what i did.I am new to jquery but have done php
$(function() {
$("#json-one").change(function() {
var dropdown = $(this);
var name=dropdown.val();
$.getJSON("categories_php?name=",{ "name": name },
function(data) {
prompt(data.name);
var $jsontwo = $("#json-two");
$jsontwo.append("<option>" + data.name + "</option>");
});
});
});
on the php page for test i have not done much
<?php
$m=new Mongo();
$db=$m->admin;
$collection=$db->categories;
$cur=$collection->find();
$name['name']= $_REQUEST['name'];
print_r(json_encode($name));
?>
Upvotes: 0
Views: 81
Reputation: 4293
You can use:
$.getJSON("categories_php",{ name: name }, function() {
//Some code
});
Upvotes: 1