0

I am sending some data as cat_id into here

$.get('/ajax3?cat_id=' +cat_id,function(data){});

I want to send multiple data like cat_id, sub_id How can I do this:

<script>
$("#cat3").on('click',function (e) {
//console.log(e);

var cat_id=document.getElementById('cat').value;
var sub_id=document.getElementById('sub').value;

    $.get('/ajax3?cat_id=' +cat_id,function(data)
    {
        $('#sub1').empty();
        $.each(data,function(index,subcatObj)
        {
            $('#sub1').append('<li>'+subcatObj.section+'</li>');
        })

    });
});

In my controller i get cat_id that i send. Now I want to pass sub_id how do I do this???

1 Answer 1

1

Well, that sounds pretty simple. You just add sub_id to the query string:

$("#cat3").on('click',function (e) {
//console.log(e);

var cat_id=document.getElementById('cat').value;
var sub_id=document.getElementById('sub').value;

    $.get('/ajax3?cat_id=' +cat_id + '&sub_id=' + sub_id  ,function(data)
    {
        $('#sub1').empty();
        $.each(data,function(index,subcatObj)
        {
            $('#sub1').append('<li>'+subcatObj.section+'</li>');
        })

    });
});

Then you can just use the Input Facade to get the parameter in your controller:

Input::get('sub_id')

Sign up to request clarification or add additional context in comments.

Comments

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.