{"id":716,"date":"2011-04-16T23:47:37","date_gmt":"2011-04-16T14:47:37","guid":{"rendered":"http:\/\/blog.t-szk.com\/?p=716"},"modified":"2020-08-18T20:29:28","modified_gmt":"2020-08-18T11:29:28","slug":"jquerypost%e9%80%81%e4%bf%a1%e3%82%92%e8%a1%8c%e3%81%86","status":"publish","type":"post","link":"https:\/\/codaholic.org\/?p=716","title":{"rendered":"[jQuery] post \u30e1\u30bd\u30c3\u30c9\u3068 ajax \u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066 POST \u9001\u4fe1\u3092\u884c\u3046\u30b5\u30f3\u30d7\u30eb"},"content":{"rendered":"<p>jQuery \u3067 POST \u9001\u4fe1\u3092\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30e1\u30bd\u30c3\u30c9\u306b ajax \u3068 post \u304c\u3042\u308a\u307e\u3059\u3002\u305d\u306e 2 \u3064\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u7528\u3044\u305f\u7c21\u5358\u306a\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\u3002\u305d\u308c\u305e\u308c post.php \u306b POST \u9001\u4fe1\u3092\u884c\u3044\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u30a2\u30e9\u30fc\u30c8\u3067\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<p><!--more--><br \/>\n\u307e\u305a\u306f post \u30e1\u30bd\u30c3\u30c9\u306e\u4f7f\u7528\u4f8b\u3067\u3059\u3002<\/p>\n<h3>post.html<\/h3>\n<pre><code class=\"language-html\">&lt;html&gt;\n&lt;head&gt;\n&lt;script type=\"text\/javascript\" src=\"jquery.js\"&gt;&lt;\/script&gt;\n&lt;script type=\"text\/javascript\"&gt;\n$(function(){\n  $('#sw').click(\n    function(){\n      $.post(\n        'post.php',\n        {\n          'pd': '\u3053\u3093\u306b\u3061\u306f'\n        },\n        function(data){\n          alert(data);\n        }\n      );\n    }\n  );\n});\n&lt;\/script&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n  &lt;a href=\"javascript: void(0)\" id=\"sw\"&gt;switch&lt;\/a&gt;&lt;br \/&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre>\n<h3>6\u884c\u76ee<\/h3>\n<p>id \u304c sw \u306b\u6307\u5b9a\u3055\u308c\u305f\u8981\u7d20\u304c\u30af\u30ea\u30c3\u30af\u3055\u308c\u305f\u6642\u306b\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<h3>8\u884c\u76ee\u304b\u308916\u884c\u76ee<\/h3>\n<p>post \u30e1\u30bd\u30c3\u30c9\u306e\u5f15\u6570\u3068\u3057\u3066\u3001post \u5148\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3001post \u3059\u308b\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u9023\u60f3\u914d\u5217\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u53d7\u3051\u53d6\u3063\u305f\u5f8c\u306b\u5b9f\u884c\u3059\u308b\u95a2\u6570\u3092\u6e21\u3057\u307e\u3059\u3002\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u53d7\u3051\u53d6\u3063\u305f\u5f8c\u306b\u5b9f\u884c\u3059\u308b\u95a2\u6570\u306b\u306f data \u304c\u5f15\u6570\u3068\u3057\u3066\u6e21\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001data \u304c\u30ec\u30b9\u30dd\u30f3\u30b9\u305d\u306e\u3082\u306e\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h4>post.php<\/h4>\n<pre><code class=\"language-php\">&lt;?php\n  echo 'your post data is ' . $_POST['pd'];\n<\/code><\/pre>\n<p>\u9001\u4fe1\u3055\u308c\u305f\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u4ed8\u3051\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3059\u3002POST \u9001\u4fe1\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092\u8868\u793a\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<p>\u6b21\u306b ajax \u30e1\u30bd\u30c3\u30c9\u306e\u4f7f\u7528\u4f8b\u3067\u3059\u3002<\/p>\n<h4>ajax.html<\/h4>\n<pre><code class=\"language-html\">&lt;html&gt;\n&lt;head&gt;\n&lt;script type=\"text\/javascript\" src=\"jquery.js\"&gt;&lt;\/script&gt;\n&lt;script type=\"text\/javascript\"&gt;\n$(function(){\n  $('#sw').click(\n    function(){\n      $.ajax({\n        type: 'post',\n        url: 'post.php',\n        data: {\n          'pd': '\u3053\u3093\u306b\u3061\u306f'\n        },\n        success: function(data){\n          alert(data);\n        }\n      });\n    }\n  );\n});\n&lt;\/script&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n  &lt;a href=\"javascript: void(0)\" id=\"sw\"&gt;switch&lt;\/a&gt;&lt;br \/&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre>\n<h3>8\u884c\u76ee\u304b\u308917\u884c\u76ee<\/h3>\n<p>ajax \u30e1\u30bd\u30c3\u30c9\u306b\u6e21\u3059\u5f15\u6570\u306f\u9023\u60f3\u914d\u5217\u306b\u306a\u308a\u307e\u3059\u3002\u6e21\u3057\u3066\u3044\u308b\u5185\u5bb9\u306f\u4e0b\u8a18\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<h4>type<\/h4>\n<p>post \u9001\u4fe1\u3092\u884c\u3046\u5834\u5408\u306f post \u3068\u3057\u307e\u3059\u3002<\/p>\n<h4>url<\/h4>\n<p>post \u9001\u4fe1\u5148\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<h4>data<\/h4>\n<p>post \u30e1\u30bd\u30c3\u30c9\u3068\u540c\u69d8\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u9023\u60f3\u914d\u5217\u3067\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<h4>success<\/h4>\n<p>\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u6210\u529f\u3057\u305f\u3068\u304d\u306b\u5b9f\u884c\u3055\u308c\u308b\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002\u3053\u3061\u3089\u3082 post \u3068\u540c\u69d8\u306b\u30ec\u30b9\u30dd\u30f3\u30b9\u3092 alert \u3067\u8868\u793a\u3059\u308b\u3060\u3051\u306e\u95a2\u6570\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>jQuery \u3067 POST \u9001\u4fe1\u3092\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30e1\u30bd\u30c3\u30c9\u306b ajax \u3068 post \u304c\u3042\u308a\u307e\u3059\u3002\u305d\u306e 2 \u3064\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u7528\u3044\u305f\u7c21\u5358\u306a\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\u3002\u305d\u308c\u305e\u308c post.php \u306b POST \u9001\u4fe1\u3092\u884c\u3044\u3001\u30ec\u30b9\u30dd\u30f3\u30b9\u3092 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[5,6],"tags":[137,245,246,136],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8gd1W-by","_links":{"self":[{"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts\/716"}],"collection":[{"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=716"}],"version-history":[{"count":24,"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts\/716\/revisions"}],"predecessor-version":[{"id":2363,"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts\/716\/revisions\/2363"}],"wp:attachment":[{"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=716"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=716"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=716"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}