0

I have 2 dynamic drop down menus using json . Then thing is with the script I'm using only one will work correctly. I'm not sure where I'm going wrong..

Edited by JorgeM: Move to appropriate forum cateogry

2
Contributors
3
Replies
18
Views
3 Years
Discussion Span
Last Post by kelley82879
0

Can I only use one? Or can I change one of them some how? As they both do similar things but are calling from a different link..

<script type="text/javascript" language="javascript">
   var url = 'http://www.klcafehelps.com/kl/build.json%3fjsonCallback%3f';
    $(document).ready(function() {
        $.ajax({
            url: url,
            type: 'GET',
            async: false,
            jsonpCallback: 'myCallback',
            contentType: "application/json",
            dataType: "jsonp",
            success: function(jd) {
                $.each(jd, function(i, value) {
                    $('#shop_name').append(
                        $('<option></option>').val(jd[i].value).html(jd[i].desc)) });
            }
        });
    });
</script>
<script type="text/javascript" language="javascript">
   var url = 'http://www.klcafehelps.com/kl/cater.json%3fjsonCallback%3f';
    $(document).ready(function() {
        $.ajax({
            url: url,
            type: 'GET',
            async: false,
            jsonpCallback: 'CaterCallBack',
            contentType: "application/json",
            dataType: "jsonp",
            success: function(jd) {
                $.each(jd, function(i, value) {
                    $('#cater_name').append(
                        $('<option></option>').val(jd[i].value).html(jd[i].desc)) });
            }
        });
    });
</script>
1

how about storing the URL info in an array, then use a loop to iterate through the array members, calling a function (passing the URL param) that executes the ajax process.

0

got it thanks

<script type="text/javascript" language="javascript">
   var caternameurl = 'http://www.klcafehelps.com/kl/cater.json%3fjsonCallback%3f';
    $(document).ready(function() {
        $.ajax({
            url: caternameurl,
            type: 'GET',
            async: false,
            jsonpCallback: 'CaterCallBack',
            contentType: "application/json",
            dataType: "jsonp",
            success: function(jd) {
                $.each(jd, function(i, value) {
                    $('#cater_name').append(
                        $('<option></option>').val(jd[i].value).html(jd[i].desc)) });
            }
        });
    });

</script>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.