﻿{"id":2753,"date":"2019-11-20T13:03:17","date_gmt":"2019-11-20T21:03:17","guid":{"rendered":"https:\/\/www.anvilsoftcraft.com\/weblog\/?p=2753"},"modified":"2019-11-20T13:13:12","modified_gmt":"2019-11-20T21:13:12","slug":"jquery%e3%81%aeajax%e3%81%a7%e3%82%b9%e3%83%86%e3%83%bc%e3%82%bf%e3%82%b9%e3%82%b3%e3%83%bc%e3%83%89%e3%81%ab0%e3%81%8c%e8%bf%94%e3%81%a3%e3%81%a6%e3%81%8f%e3%82%8b%e5%a0%b4%e5%90%88","status":"publish","type":"post","link":"https:\/\/www.anvilsoftcraft.com\/weblog\/?p=2753","title":{"rendered":"JQuery\u306eajax\u3067\u30b9\u30c6\u30fc\u30bf\u30b9\u30b3\u30fc\u30c9\u306b0\u304c\u8fd4\u3063\u3066\u304f\u308b\u5834\u5408"},"content":{"rendered":"<p>\u4e45\u3005\u306e\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u30e1\u30e2\u266a<br \/>\nJQuery\u306eajax\u3092\u4f7f\u3063\u3066PHP\u306e\u5916\u90e8\u30b3\u30fc\u30c9\u304b\u3089\u5024\u3092\u53d6\u5f97\u3059\u308b\u306e\u306b\u3053\u3093\u306a\u611f\u3058\u306e\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u307f\u305f\u3002<\/p>\n<pre>$(\"#test_btn\").on(\"click\",function(){\r\n    var param = {\"action\": \"getText\"};\r\n    $.ajax({\r\n        type: \"GET\",\r\n        url: \"getText.php\",\r\n        data: param\r\n    })\r\n    .done(function(data){\r\n        console.log(data);\r\n    })\r\n    .fail(function(data, textStatus, errorThrown){\r\n        alert(\"\u901a\u4fe1\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002\");\r\n        console.log(data);\r\n    });\r\n});\r\n<\/pre>\n<p>\u547c\u3073\u51fa\u3055\u308c\u308b<strong>getText.php<\/strong>\u306e\u30b3\u30fc\u30c9\u306f\u305f\u3063\u305f\u3053\u308c\u3060\u3051\u3002\u307b\u3093\u3068\u306f\u51e6\u7406\u304c\u5165\u308b\u3051\u3069\u7c21\u7565\u5316\u3057\u3066\u307f\u305f\u3002<\/p>\n<pre>\r\n<?php\r\necho \"TRUE\";\r\n?>\r\n<\/pre>\n<p>\u3067\u3001\u3053\u308c\u304cstatus=0\u3001statusText=&#8221;error&#8221;\u3092\u8fd4\u3059\u306e\u3067\u3059\u306a\u3002\u76f4\u524d\u307e\u3067\u540c\u3058\u30b3\u30fc\u30c9\u3067\u901a\u5e38\u306b200\u304c\u8fd4\u3063\u3066\u304d\u3066\u3044\u305f\u306e\u3060\u3051\u3068\u30ef\u30b1\u304c\u308f\u304b\u3089\u305a\u30cf\u30de\u3063\u3066\u3057\u307e\u3063\u305f\u3002\u3002\u3002<br \/>\n\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u306f\u3042\u308b\u3051\u3069\u3082\u3061\u308d\u3093\u30d6\u30e9\u30a6\u30b6\u3067\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3061\u3083\u3093\u3068\u8868\u793a\u3055\u308c\u308b\u3053\u3068\u306f\u78ba\u8a8d\u6e08\u307f\u3002<\/p>\n<pre>\r\nreadyState: 0\r\nresponseText: \"\"\r\nstatus: 0\r\nstatusText: \"error\"\r\n<\/pre>\n<p>\u3044\u308d\u3044\u308d\u8abf\u3079\u3066\u307f\u3066\u308f\u304b\u3063\u305f\u306e\u306f\u3001\u305d\u3082\u305d\u3082\u30b9\u30c6\u30fc\u30bf\u30b9\u3067\u30b5\u30fc\u30d0\u306f0\u3092\u8fd4\u3055\u306a\u3044\u306e\u3067(404\u3068\u304b50x\u3068\u304b\u304c\u8fd4\u308b\uff09CrossOrigin\u3067\u30d6\u30ed\u30c3\u30af\u3055\u308c\u305f\u304bURL\u9593\u9055\u3044\u304c\u6fc3\u539a\u3002\u3057\u304b\u3057\u3069\u3061\u3089\u3082\u5f53\u3066\u306f\u307e\u3089\u305a\u3002<\/p>\n<p>\u6700\u7d42\u7684\u306b\u5206\u304b\u3063\u305f\u306e\u306f\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u8fd4\u3063\u3066\u304f\u308b\u524d\u306b\u8868\u793a\u3055\u308c\u3066\u308b\u307f\u305f\u3044\u3002\u3068\u3044\u3046\u308f\u3051\u3067<\/p>\n<pre>$(\"#test_btn\").on(\"click\",function(){\r\n    var param = {\"action\": \"getText\"};\r\n    $.ajax({\r\n        type: \"GET\",\r\n        async: false,\r\n        url: \"getText.php\",\r\n        data: param\r\n    })\r\n    .done(function(data){\r\n        console.log(data);\r\n    })\r\n    .fail(function(data, textStatus, errorThrown){\r\n        alert(\"\u901a\u4fe1\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002\");\r\n        console.log(data);\r\n    });\r\n});\r\n<\/pre>\n<p>\u3068\u4ee5\u4e0b\u3092\u8ffd\u52a0\u3057\u3066<\/p>\n<pre>\r\nasync: false,\r\n<\/pre>\n<p>\u975e\u540c\u671f\u901a\u4fe1\u3092\u540c\u671f\u901a\u4fe1\u306b\u3057\u305f\u3089\u3061\u3083\u3093\u3068\u884c\u3051\u305f\u3002\u30ed\u30c3\u30af\u3055\u308c\u308b\u306e\u3067\u4f7f\u3044\u305f\u304f\u306a\u3044\u3051\u3069\u3002\u3002\u3002<br \/>\n\u3053\u308c\u3084\u308b\u306a\u3089timeout\u5165\u308c\u306a\u3044\u3068\u3002\u3002\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e45\u3005\u306e\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u30e1\u30e2\u266a JQuery\u306eajax\u3092\u4f7f\u3063\u3066PHP\u306e\u5916\u90e8\u30b3\u30fc\u30c9\u304b\u3089\u5024\u3092\u53d6\u5f97\u3059\u308b\u306e\u306b\u3053\u3093\u306a\u611f\u3058\u306e\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u307f\u305f\u3002 $(&#8220;#test_btn&#8221;).on(&#8220;click&#8221;,function(){ var para &hellip; <a href=\"https:\/\/www.anvilsoftcraft.com\/weblog\/?p=2753\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-2753","post","type-post","status-publish","format-standard","hentry","category-software-development"],"_links":{"self":[{"href":"https:\/\/www.anvilsoftcraft.com\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/2753","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.anvilsoftcraft.com\/weblog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.anvilsoftcraft.com\/weblog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.anvilsoftcraft.com\/weblog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.anvilsoftcraft.com\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2753"}],"version-history":[{"count":0,"href":"https:\/\/www.anvilsoftcraft.com\/weblog\/index.php?rest_route=\/wp\/v2\/posts\/2753\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.anvilsoftcraft.com\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2753"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.anvilsoftcraft.com\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2753"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.anvilsoftcraft.com\/weblog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2753"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}