jquery serialize and $.post

前端 未结 7 915
独厮守ぢ
独厮守ぢ 2020-12-01 12:32

I\'m trying to send a lot of data from a form using the $.post method in jQuery. I\'ve used the serialize() function first to make all the form data into one long string whi

7条回答
  •  被撕碎了的回忆
    2020-12-01 13:02

    Try this syntax. I use this to serialize a form and POST via ajax call to WCF service. Also, you can send this back a single JSON object instead of building the object the way you are. Try this:

    var serializedForm = serializedForm = $("#addShowForm").serializeArray();
    
    $.post("includes/add_show.php", 
        {
            "myObjectName": ("#showTitle").val(), results: perfTimes 
        }, function(data) 
            {
                $("#addShowSuccess").empty()
                .slideDown("slow")
                .append(JSON.stringify(serializedForm)); 
            });
    

提交回复
热议问题