0

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));

?>

1 Answer 1

1

You can use:

 $.getJSON("categories_php",{ name: name }, function() {
      //Some code
 }); 
Sign up to request clarification or add additional context in comments.

2 Comments

used that too no luck
umm..the url is correct but i forgot the extension .php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.