[Solved] need to ajaxify my code


So, here’s what I’ve put together. You’ll need to make a few changes as to the URL in the ajax part, how the return data is handled.
JS Fiddle: http://jsfiddle.net/fzzcdsa7/

Code:

<form name="form1" id="form1">
<input type="hidden" id="productid" name="productid" />
<input type="hidden" id="command" name="command" />
</form>

function addtocart(pid){
    $("#productid").val(pid);
    $("#command").val('add');
    ajaxSubmit();
}
function ajaxSubmit() {
    $.ajax({
      type: "POST",
      url: "mypage.php",
        data: {"productid": $("#productid").val(), "command": $("#command").val()},
        success: function(returnedData) {
             alert(returnedData);   
        }
    });   
}
addtocart(12); // addtocart( _ ID _ );

1

solved need to ajaxify my code