{"id":4749,"date":"2016-01-20T15:20:52","date_gmt":"2016-01-20T07:20:52","guid":{"rendered":"https:\/\/sdeno.com\/?p=4749"},"modified":"2019-02-22T11:33:37","modified_gmt":"2019-02-22T03:33:37","slug":"php%e4%b8%8a%e4%bc%a0%e7%be%8e%e5%8c%96%e4%b8%8a%e4%bc%a0%e6%8c%89%e9%92%ae%e4%bb%a5%e5%8f%8a%e5%a4%9a%e9%80%89%e5%9b%be%e7%89%87%e4%b8%8a%e4%bc%a0","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=4749","title":{"rendered":"\u5229\u7528jquery.form.js php\u4e0a\u4f20\u7f8e\u5316\u4e0a\u4f20\u6309\u94ae\u4ee5\u53ca\u591a\u9009\u56fe\u7247\u4e0a\u4f20"},"content":{"rendered":"<p><span style=\"color: #ff0000;\">1,<\/span> \u7f8e\u5316\u9ed8\u8ba4\u4e0a\u4f20\u6309\u94ae<\/p>\n<p>\u5728\u8c37\u6b4c\u548cIE\u4e0b\u4f7f\u7528\u9ed8\u8ba4\u7684\u4e0a\u4f20\u7ec4\u4ef6\uff0c\u5982\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre> &lt;input type=\"file\" name=\"userfile\" id=\"xFile\"&gt;<\/pre>\n<p>\u663e\u793a\u7684\u754c\u9762\u90fd\u4e0d\u4e00\u6837\u4e5f\u5f88\u4e11\uff0c\u4e3a\u4e86\u7f8e\u5316\u5e76\u4e14\u7edf\u4e00\u4e00\u4e0b\u754c\u9762\u53ef\u4ee5\u4f7f\u7528\uff1a<\/p>\n<pre>&lt;label class=\"ui_button ui_button_primary\" for=\"xFile\"&gt;\u4e0a\u4f20\u6587\u4ef6&lt;\/label&gt;\r\n &lt;input type=\"file\" name=\"userfile\" id=\"xFile\" style=\"position:absolute;clip:rect(0 0 0 0);\"&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>\u6837\u5f0f\uff1a<\/p>\n<pre>.ui_button {\r\n display: inline-block;\r\n line-height: 38px;\r\n font-size: 14px;\r\n text-align: center;\r\n color: #545A6C;\r\n border: 1px solid #d0d0d5;\r\n border-radius: 4px;\r\n padding: 0 15px;\r\n min-width: 50px;\r\n background-color: #fff;\r\n background-repeat: no-repeat;\r\n background-position: center;\r\n -webkit-transition: border-color .15s, background-color .15s;\r\n transition: border-color .15s, background-color .15s;\r\n outline: 0 none;\r\n cursor: pointer;\r\n overflow: visible;\r\n}\r\n.ui_button_primary, .ui_button_primary.disabled:hover, .ui_button_primary.ui_button_loading:hover {\r\n border: 1px solid #00a5e0;\r\n background-color: #00a5e0;\r\n color: #fff;\r\n}<\/pre>\n<p>\u6548\u679c\uff1a<\/p>\n<p><a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/01\/good_upbt.jpg\"><figure class=\"mdx-lazyload-container\" style=\"max-width:142px\"><div style=\"padding-top:59.154929577465%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"142\" height=\"84\" class=\"alignnone size-full wp-image-4750 lazyload\" title=\"good_upbt\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/01\/good_upbt.jpg\" alt=\"good_upbt\"><\/figure><\/a><br \/>\n<span style=\"color: #ff0000;\">2<\/span>\uff0cajax\u63d0\u4ea4\u6570\u636e jquery.form.js<\/p>\n<p>\u6211\u4eec\u4e0d\u7ba1\u4e0a\u4f20\u56fe\u7247\u8fd8\u662f\u63d0\u4ea4\u6570\u636e\uff0c\u9ed8\u8ba4\u7684\u884c\u4e3a\u90fd\u4f1a\u5237\u4e0b\u4e00\u4e0b\u6216\u8005\u662f\u95ea\u70c1\u4e00\u4e0b\u9875\u9762\u624d\u80fd\u628a\u6570\u636e\u63d0\u4ea4\u5230\u670d\u52a1\u5668\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528jquery.form.js\u63d2\u4ef6\u5176\u5b9e\u4e5f\u5c31\u662f\u5229\u7528ajax\u63d0\u4ea4\u6570\u636e\u3002<br \/>\njquery.form.js\u6709\u4e24\u4e2a\u6838\u5fc3\u65b9\u6cd5 ajaxForm()\u548cajaxSubmit()<br \/>\n\u573a\u666f1\uff1a(\u63a8\u8350)<br \/>\n\u5982\u679c\u6ca1\u6709\u7ed3\u5408\u5176\u4ed6\u7684\u63d2\u4ef6\u4f7f\u7528\u4e0a\u4f20\u529f\u80fd\u7684\u8bdd\uff0c\u5c31\u5355\u5355\u4f7f\u7528jquery.form.js\u7684\u8bdd\u5c31\u76f4\u63a5\u4f7f\u7528ajaxForm()<br \/>\n\u6709&lt;form&gt; \u6709&lt;input type=&#8221;submit&#8221;&gt;,\u4ee3\u7801\u53ef\u4ee5\u76f4\u63a5\u5982\u4e0b\uff1a<\/p>\n<pre>$('#reg').ajaxForm();<\/pre>\n<p>\u8fd9\u6837\u5c31\u53ef\u4ee5\u5728\u5237\u65b0\u4e0b\u5b9e\u73b0\u63d0\u4ea4\u6570\u636e\u7684\u529f\u80fd\uff0c\u4e5f\u81ea\u52a8\u963b\u6b62\u4e86\u8df3\u8f6c\u9ed8\u8ba4\u884c\u4e3a\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u573a\u666f2\uff1a<br \/>\n\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662fjquery\u4e2dsubmit()\u65b9\u6cd5\u6216\u8005\u4e0d\u662f\u901a\u8fc7form\u63d0\u4ea4\u7684\u53c8\u8981\u7ed3\u5408jquery.form.js\uff0c\u4f60\u5c31\u8981\u4f7f\u7528ajaxSubmit()<br \/>\n\u4f7f\u7528jquery\u4e2d\u7684submit()\u65b9\u6cd5\u4e0b\u4f7f\u7528<\/p>\n<pre>$('#reg').submit(function(){\r\n   $(this).ajaxSubmit();\r\n   return false;\r\n});<\/pre>\n<p>&nbsp;<\/p>\n<p>\u53c2\u6570\uff1a<\/p>\n<pre>$('#reg').submit(function () {\r\n  $(this).ajaxSubmit({\r\n    url : 'test1.php', \/\/\u5411\u54ea\u4e2a\u9875\u9762\u63d0\u4ea4\u6570\u636e\r\n    target : '#box', \/\/\u63d0\u4ea4\u6570\u636e\u6210\u529f\u540e\u8fd4\u56de\u7684\u5185\u5bb9\u8981\u5b58\u653e\u7684\u5730\u65b9\r\n    type : 'GET',\r\n    dataType : null,\r\n    clearForm : true, \/\/\u6570\u636e\u63d0\u4ea4\u6210\u529f\u540e\uff0c\u6e05\u7a7a\u8868\u5355\uff0c\u5305\u62ec\u9ed8\u8ba4\u7684\u8bbe\u7f6e\u597d\u7684value\u4e5f\u6e05\u7a7a\r\n    resetForm : true, \/\/\u6570\u636e\u63d0\u4ea4\u6210\u529f\u540e\uff0c\u91cd\u7f6e\u8868\u5355\uff0c\u4e0d\u6e05\u7a7a\u9ed8\u8ba4\u8bbe\u7f6e\u597d\u7684value\r\n    data : { \/\/\u63d0\u4ea4\u6570\u636e\u7684\u540c\u65f6\u81ea\u5b9a\u4e49\u6570\u636e\u63d0\u4ea4\r\n      aaa : 'bbb',\r\n    },\r\n    beforeSubmit : function (formData, jqForm, options) {\r\n    \/\/\u63d0\u4ea4\u4e4b\u524d\u6267\u884c\uff0c\u4e00\u822c\u7528\u4e8e\u6570\u636e\u9a8c\u8bc1\r\n    \/\/alert(options.url); \/\/ \u5f97\u5230url\u503c\r\n    \/\/alert(jqForm.html()); \u5f97\u5230form\u91cc\u9762\u7684html\r\n    \/\/alert(formData[0].name); \/\/\u5f97\u5230\u7b2c\u4e00\u4e2ainput\u7684name\u5c5e\u6027\u7684\u503c\r\n    \/\/alert(formData[0].value);\/\/\u5f97\u5230\u7b2c\u4e00\u4e2ainput\u7684value\u5c5e\u6027\u7684\u503c\r\n\r\n\r\n    \/\/\u5982\u679c\u6570\u636e\u9a8c\u8bc1\u4e0d\u5408\u6cd5\uff0c\u5c31\u8fd4\u56defalse\uff0c\u4e0d\u8ba9\u63d0\u4ea4\uff0c\u8fd4\u56detrue\u8ba9\u63d0\u4ea4\r\n       return true;\r\n    },\r\n    success : function (responseText, statusText) {\r\n      alert(responseText + statusText); \/\/\u5f97\u5230\u56de\u8c03\u7684\u5185\u5bb9 \u548c\u72b6\u6001(success)\r\n    },\r\n    error : function (event, errorText, errorType) {\r\n      alert(errorText + errorType); \/\/\u4e3b\u8981\u662ferrorType\u63d0\u793a\u9519\u8bef\u7c7b\u578b\r\n    },\r\n  });\r\n  return false;\r\n});\r\n*\/\r\n\r\n\/\/submit()\u65b9\u6cd5\u6ca1\u6709\u963b\u6b62\u9ed8\u8ba4\u63d0\u4ea4\uff0c\u9700\u8981\u81ea\u884c\u963b\u6b62\r\n\r\n\/\/\u5de5\u5177\u65b9\u6cd5\r\n\/\/alert($('#reg').formSerialize());\u5e8f\u5217\u5316\u8868\u5355\u7684\u5185\u5bb9 user=123&amp;pass=123\r\n\/\/alert($('#reg #user').fieldSerialize()); \u83b7\u53d6\u67d0\u4e2ainput\u7684\u503c\u5e76\u5e8f\u5217\u5316user=123\r\n\/\/alert($('#reg #user').fieldValue()); \u83b7\u53d6\u67d0\u4e2ainput\u7684\u503c 123\r\n\/\/alert($('#reg').resetForm()); \/\/\u91cd\u7f6e\u6574\u4e2a\u8868\u5355\r\nalert($('#reg #user').clearFields()); \/\/\u6e05\u7a7a\u67d0\u4e2a\u8868\u5355<\/pre>\n<p>&nbsp;<\/p>\n<p>html:<\/p>\n<pre>&lt;form id=\"reg\" action=\"\" method=\"\"&gt;  \/\/\u5982\u679cjs\u4e2d\u6709\u8bbe\u7f6eurl\u548ctype\u8fd9\u91cc\u7684action\u548cmethod\u5c31\u6ca1\u5fc5\u8981\u8bbe\u7f6e\u4e86\r\n    &lt;input&gt; \r\n    &lt;input type=\"submit\" value=\"\u63d0\u4ea4\"&gt;\r\n&lt;\/form&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>3,\u540c\u65f6\u9009\u53d6\u591a\u56fe\u7247\u4e0a\u4f20 \u548c \u4e8b\u5148\u56fe\u7247\u9884\u89c8<\/p>\n<p>\u6700\u4f4e\u517c\u5bb9IE10<\/p>\n<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/01\/html5up.jpg\"><figure class=\"mdx-lazyload-container\" style=\"max-width:427px\"><div style=\"padding-top:41.686182669789%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"427\" height=\"178\" class=\"alignnone size-full wp-image-4753 lazyload\" title=\"html5up\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/01\/html5up.jpg\" alt=\"html5up\" data-srcset=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/01\/html5up.jpg 427w, https:\/\/sdeno.com\/wp-content\/uploads\/2016\/01\/html5up-300x125.jpg 300w\" sizes=\"auto, (max-width: 427px) 100vw, 427px\"><\/figure><\/a>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/01\/imgup.rar\">imgup<\/a><\/p>\n<p>\u6d4b\u8bd5\u5305\uff1a<a href=\"http:\/\/pan.baidu.com\/s\/1i4mzKYL\" target=\"_blank\" rel=\"noopener\">http:\/\/pan.baidu.com\/s\/1i4mzKYL<\/a><\/p>\n<p>\u4e0b\u8f7d\uff1a<a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/01\/jquery.form_.min_.txt\">jquery.form.min<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-\u6848\u4f8b&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<figure class=\"mdx-lazyload-container\" style=\"max-width:390px\"><div style=\"padding-top:33.589743589744%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"390\" height=\"131\" class=\"alignnone size-full wp-image-7241 lazyload\" title=\"\u5229\u7528jquery.form.js php\u4e0a\u4f20\u7f8e\u5316\u4e0a\u4f20\u6309\u94ae\u4ee5\u53ca\u591a\u9009\u56fe\u7247\u4e0a\u4f20\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/01\/pic.jpg\" alt=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/01\/pic.jpg\" data-srcset=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/01\/pic.jpg 390w, https:\/\/sdeno.com\/wp-content\/uploads\/2016\/01\/pic-300x101.jpg 300w\" sizes=\"auto, (max-width: 390px) 100vw, 390px\"><\/figure>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2016\/01\/txt_daima.txt\">txt_daima<\/a><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n<p><audio style=\"display: none;\" controls=\"controls\"><\/audio><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1, \u7f8e\u5316\u9ed8\u8ba4\u4e0a\u4f20\u6309\u94ae \u5728\u8c37\u6b4c\u548cIE\u4e0b\u4f7f\u7528\u9ed8\u8ba4\u7684\u4e0a\u4f20\u7ec4\u4ef6\uff0c\u5982\u4ee5\u4e0b\u4ee3\u7801\uff1a &lt;input type=&#8221;fil [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30,11],"tags":[],"class_list":["post-4749","post","type-post","status-publish","format-standard","hentry","category-php","category-11"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/4749","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4749"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/4749\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}