How do I make a jQuery POST function open the new page?

Posted by ciclistadan on Stack Overflow See other posts from Stack Overflow or by ciclistadan
Published on 2010-04-18T05:18:27Z Indexed on 2010/04/18 5:23 UTC
Read the original article Hit count: 504

Filed under:
|
|
|

I know that a submit button in HTML can submit a form which opens the target page, but how do I cause a jQuery ajax call POST information to a new page and display the new page. I am submitting information that is gathered by clicking elements (which toggle a new class) and then all items with this new class are added to an array and POSTed to a new page. I can get it to POST the data but it seems to be working functioning in an ajax non-refreshing manner, not submitting the page and redirecting to the new page. how might I go about doing this?

here's the script section:

//onload function
$(function() {

//toggles items to mark them for purchase
//add event handler for selecting items
$(".line").click(function() {
    //get the lines item number
    var item = $(this).toggleClass("select").attr("name");
    });

$('#process').click(function() {
    var items = [];

    //place selected numbers in a string    
    $('.line.select').each(function(index){
            items.push($(this).attr('name'));
            });

    $.ajax({
            type: 'POST',
            url:  'additem.php',
            data: 'items='+items,
            success: function(){
                $('#menu').hide(function(){
                    $('#success').fadeIn();             
                    });
                }   
            });
    });
    return false;
});

any pointers would be great!! thanks

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript