1.jq是透過ajax上傳
$.ajax({ url: "test.html", context: document.body, success: function(){ $(this).addClass("done"); }});
2.透過form表單提交
$(function() { $("#submit").click(function() { var d = {}; var t = $("form").serializeArray(); //t的值為[{name: "a1", value: "xx"}, //{name: "a2", value: "xx"}...] $.each(t, function() { d[this.name] = this.value; }); alert(JSON.stringify(d)); }); });
1.jq是透過ajax上傳
$.ajax({ url: "test.html", context: document.body, success: function(){ $(this).addClass("done"); }});
2.透過form表單提交
$(function() { $("#submit").click(function() { var d = {}; var t = $("form").serializeArray(); //t的值為[{name: "a1", value: "xx"}, //{name: "a2", value: "xx"}...] $.each(t, function() { d[this.name] = this.value; }); alert(JSON.stringify(d)); }); });