form表單數據的封裝

function fsq() {

    var fmStr = "fm=fm";

    var fmE = document.fm.elements;

    for (var i = 0; i < fmE.length; i++) {

       fmStr += "&" + fmE[i].name + "=" + fmE[i].value;

    }

    $.ajax({

              type : "POST",

              url : "1.jsp",

              data : fmStr,

              success : function(msg) {

                  var dataRs = eval("(" + msg + ")");

                  alert("Data Saved: " + dataRs.msg);

              }

           });

}

You May Also Like