ethio
ethio

Reputation: 539

JQuery Sending value using GET not working

Sending the value of the select option is not working but I am able to get the value and print it, so it's definitely the $.get.

$(document).ready(function () {    
//hover method to drop down nav menu
.
.
.
.

$('select').change( function() {
    var val = $('#sortOpt').val();
    $.get(
        "http://localhost/e-com/index.php/products/categories?cat=cameras&",
        {
            sort: val
        },
        function(data){}
    )
});
});

Upvotes: 0

Views: 37

Answers (2)

Shimon Rachlenko
Shimon Rachlenko

Reputation: 5517

You should send data as url parameters:

$.get(
    "http://localhost/e-com/index.php/products/categories?cat=cameras&sort=" + val,
    function(data){}
});

Upvotes: 0

Wilmer
Wilmer

Reputation: 2511

You need to fix the following :

   var val = $('#sortOpt').val();
//^remove the '$'

You've also got an extra } at the end of your $.get() call.

Once fixed, you should have:

$('select').change( function() {
    var val = $('#sortOpt').val();
    $.get(
        "http://localhost/e-com/index.php/products/categories?cat=cameras&",
        {
            sort: val
        },
        function(data){}
    );
});

Upvotes: 1

Related Questions