简体   繁体   中英

How can I send a javascript object and form data $.post()

I am trying to send a javascript object along with some form data using the short hand $.post().

I am trying to combine the 2 together but having a hard time doing so. Also how would i be able to retrieve the form data in my php page?

Any help would be really appreciated! Thanks!

$("#copy_options").on("click", function(){

    $.post("copyOptions.php",{menu_item_ids : item_ids} $("#optionsMenu").serialize(); )

        .fail(function(){
           // console.log("Ajax Failed");
        })


        .done(function () {

            //console.log("Ajax has been complete");

        });


    });

Try this

$("#copy_options").on("click", function(){
  var dataObj={
     serializeData:$("#optionsMenu").serialize(),
    menu_item_ids :item_ids
}
    $.post("copyOptions.php",dataObj )

        .fail(function(){
           // console.log("Ajax Failed");
        })


        .done(function () {

            //console.log("Ajax has been complete");

        });


    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM