My AJAX is only firing once,

Posted by sea_1987 on Stack Overflow See other posts from Stack Overflow or by sea_1987
Published on 2010-04-12T15:30:18Z Indexed on 2010/04/12 15:33 UTC
Read the original article Hit count: 515

Filed under:
|
|
|

Hi There,

I ahave some ajax that is fired when a checkbox is clicked, it essentially sends a query string to a PHP script and then returns the relevant HTML, however, if I select a select it works fine if I then slect another checkbox as well as the previous I get no activity what so ever, not even any errors in firebug, it is very curious, does anyone have any ideas?

//Location AJAX
//var dataObject = new Object();
var selected = new Array();
//alert(selected);
$('#areas input.radio').change(function(){ // will trigger when the checked status changes
    var checked = $(this).attr("checked"); // will return "checked" or false I think.
    // Do whatever request you like with the checked status
    if(checked == true) {
        //selected.join('&');
        selected = $('input:checked').map(function() {
            return $(this).attr('name')+"="+$(this).val();
        }).get();

            getQuery = selected.join('&')+"&location_submit=Next";
            alert(getQuery);
            $.ajax({
                type:"POST",
                url:"/search/location",
                data: getQuery,
                success:function(data){
                    //alert(getQuery);
                    //console.log(data);
                    $('body.secEmp').html(data);
                }
            });
    } else {
        //do something to remove the content here
        alert($(this).attr('name'));
    }
});

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ajax