{"id":909,"date":"2020-08-10T17:04:02","date_gmt":"2020-08-10T09:04:02","guid":{"rendered":"http:\/\/blog.yyhcw.com\/?p=909"},"modified":"2020-08-10T17:04:02","modified_gmt":"2020-08-10T09:04:02","slug":"js-function%e5%bc%82%e6%ad%a5%e6%89%a7%e8%a1%8c%e6%94%b9%e5%90%8c%e6%ad%a5-ajax%e5%bc%82%e6%ad%a5%e5%ae%8c%e6%88%90%e5%90%8e%e5%86%8d%e6%89%a7%e8%a1%8c%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"http:\/\/blog.yyhcw.com\/post\/909.html","title":{"rendered":"js function\u5f02\u6b65\u6267\u884c\u6539\u540c\u6b65-ajax\u5f02\u6b65\u5b8c\u6210\u540e\u518d\u6267\u884c\u64cd\u4f5c"},"content":{"rendered":"<!--wp-compress-html--><!--wp-compress-html no compression--><p>\u4eca\u5929\u9047\u5230\u4e00\u4e2a\u95ee\u9898\uff0c\u5c31\u662f\u60f3\u5c06\u7edf\u4e00\u7684\u5904\u7406\u65b9\u6cd5\u653e\u5230\u4e00\u4e2aJS function\u51fd\u6570\u4e2d,\u4e8e\u662f\u5199\u4e86\u65b9\u6cd5\uff1a<\/p>\n<pre class=\"lang:js decode:true\">function changeand<a href=\"http:\/\/blog.yyhcw.com\/post\/tag\/ajax\" class=\"tag-tooltip\" data-toggle=\"tooltip\" title=\"\u67e5\u770b\u66f4\u591a\u5173\u4e8e ajax \u7684\u6587\u7ae0\" target=\"_blank\">ajax<\/a>(data,url) {\r\n        layer.confirm('\u786e\u5b9a\u8981\u5220\u9664\u9009\u4e2d\uff1f', function(index){\r\n            var ids=new Array();\r\n            for (var i = 0; i &lt; data.length; i++) {\r\n                ids.push(data[i].id);\r\n            }\r\n            $.post(url, {id:ids.join(\",\")}, function (result) {\r\n                layer.msg(result.msg, {}, function () {\r\n                    res(result.code)\r\n                });\r\n\r\n            });\r\n        });\r\n}<\/pre>\n<p>\u8fd9\u4e2a\u662f\u7edf\u4e00\u7684\u591a\u9009\u5220\u9664\uff0c\u5916\u9762\u8c03\u7528\u5c31\u662f\u7b80\u5355\u7684\uff1a<\/p>\n<pre class=\"lang:php decode:true \">isok = changeand<a href=\"http:\/\/blog.yyhcw.com\/post\/tag\/ajax\" class=\"tag-tooltip\" data-toggle=\"tooltip\" title=\"\u67e5\u770b\u66f4\u591a\u5173\u4e8e ajax \u7684\u6587\u7ae0\" target=\"_blank\">ajax<\/a>(data,'http:\/\/blog.yyhcw.com');\r\nalert(isok);<\/pre>\n<p>\u4e8e\u662f\u4e4e\u5c31\u51fa\u73b0\u4e86\u95ee\u9898\uff0c\u5c31\u662f\u5728<a href=\"http:\/\/blog.yyhcw.com\/post\/tag\/ajax\" class=\"tag-tooltip\" data-toggle=\"tooltip\" title=\"\u67e5\u770b\u66f4\u591a\u5173\u4e8e ajax \u7684\u6587\u7ae0\" target=\"_blank\">ajax<\/a>\u672a\u6210\u529f\u4e4b\u524d\u5c31\u6267\u884c\u4e86alert\u547d\u4ee4\uff0c\u6709\u65f6\u5019\u751a\u81f3\u662falert\u6267\u884c\u65e9\u4e8e\u51fd\u6570\uff0c\u5e76\u4e0d\u662f\u8ba4\u4e3a\u7684\u4e00\u884c\u4e00\u884c\u6267\u884c\u7684\u987a\u5e8f\uff0c\u597d\u751f\u5947\u602a\uff01\u95ee\u4e86\u540c\u4e8b\u624d\u77e5\u9053\u539f\u6765\u8fd9\u6837\u7684\u5c31\u662f\u5f02\u6b65\u6267\u884c\u6216\u5f02\u6b65\u8bf7\u6c42\u4e86\uff0c\u8981\u6539\u6210\u540c\u6b65\u6267\u884c\u624d\u53ef\u4ee5\uff01\u8bdd\u4e0d\u591a\u8bf4\u76f4\u63a5\u4e0a\u4fee\u6539\u540e\u7aef\u4ee3\u7801\uff1a<\/p>\n<pre class=\"lang:js decode:true\">function changeand<a href=\"http:\/\/blog.yyhcw.com\/post\/tag\/ajax\" class=\"tag-tooltip\" data-toggle=\"tooltip\" title=\"\u67e5\u770b\u66f4\u591a\u5173\u4e8e ajax \u7684\u6587\u7ae0\" target=\"_blank\">ajax<\/a>(data,url) {\r\n    return new Promise((res,rel) =&gt; {\r\n        layer.confirm('\u786e\u5b9a\u8981\u5220\u9664\u9009\u4e2d\uff1f', function(index){\r\n            var ids=new Array();\r\n            for (var i = 0; i &lt; data.length; i++) {\r\n                ids.push(data[i].id);\r\n            }\r\n            $.post(url, {id:ids.join(\",\")}, function (result) {\r\n                layer.msg(result.msg, {}, function () {\r\n                    res(result.code)\r\n                });\r\n\r\n            });\r\n        });\r\n    })\r\n}<\/pre>\n<p>\u524d\u53f0\u8c03\u7528\u4e5f\u8981\u4fee\u6539\u6210\uff1a<\/p>\n<pre class=\"lang:js decode:true \">changeandajax(data,'{:url(\"AdminOrder\/delete\")}').then(result =&gt; {\r\n                    if(result==0){\r\n                        table.reload('yingTable');\r\n                    }\r\n                });<\/pre>\n<p>\u8fd9\u6837\u5c31\u5b8c\u6210\u4e86ajax\u5f02\u6b65\u5b8c\u6210\u540e\u518d\u6267\u884c\u8868\u683c\u5237\u65b0\u64cd\u4f5c\uff0c\u5b8c\u7f8e\u89e3\u51b3\u95ee\u9898\uff01<\/p>\n<p>\u8bb0\u5f55\u4e0b\u6280\u672f\u5c0f\u7ed3\uff0c\u4ee5\u540e\u5fc5\u5b9a\u4f1a\u9047\u5230\u8fd9\u6837\u7684\u95ee\u9898\uff01<\/p>\n<!--wp-compress-html no compression--><!--wp-compress-html-->","protected":false},"excerpt":{"rendered":"\u4eca\u5929\u9047\u5230\u4e00\u4e2a\u95ee\u9898\uff0c\u5c31\u662f\u60f3\u5c06\u7edf\u4e00\u7684\u5904\u7406\u65b9\u6cd5\u653e\u5230\u4e00\u4e2aJS function\u51fd\u6570\u4e2d,\u4e8e\u662f\u5199\u4e86\u65b9\u6cd5\uff1a function \u00b7\u00b7\u00b7","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[237],"views":158559,"_links":{"self":[{"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/posts\/909"}],"collection":[{"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/comments?post=909"}],"version-history":[{"count":0,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/posts\/909\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/media?parent=909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/categories?post=909"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/tags?post=909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}