Skip to content

Instantly share code, notes, and snippets.

@tokkonopapa
Created June 11, 2011 09:04
Show Gist options
  • Save tokkonopapa/1020389 to your computer and use it in GitHub Desktop.
Save tokkonopapa/1020389 to your computer and use it in GitHub Desktop.
/echo/json/
/* /echo/json/ */
<div id="result"></div>
$(function(){
// jQuery.post()
$.post("/echo/json/", {
json: $.toJSON({
"1st": "ヤクルト",
"2nd": "中日",
"3rd": "巨人"
}),
deley: 1
}).success(function(data, textStatus, jqXHR) {
$("#result").append("<p>1st:" + data["1st"] + ", 2nd:" + data["2nd"] + ", 3rd:" + data["3rd"] + "</p>");
});
// jQuery.ajax()
$.ajax({
type: 'POST',
dataType: "json",
url: "/echo/json/",
data: {
json: $.toJSON({
"1st": "ソフトバンク",
"2nd": "日本ハム",
"3rd": "西武"
}),
deley: 3
}
}).success(function(data, textStatus, jqXHR) {
$("#result").append("<p>1st:" + data["1st"] + ", 2nd:" + data["2nd"] + ", 3rd:" + data["3rd"] + "</p>");
});
// jQuery.getJSON() は GET のため、使用不可
$.getJSON("/echo/json/", {
json: $.toJSON({
"1st": "阪神",
"2nd": "ロッテ",
"3rd": "広島"
}),
deley: 5
}).success(function(data, textStatus, jqXHR) {
$("#result").append("<p>1st:" + data["1st"] + ", 2nd:" + data["2nd"] + ", 3rd:" + data["3rd"] + "</p>");
});
});
name: /echo/json/
description: /echo/json のテスト
authors:
- tokkonopapa
resources:
- http://jquery-json.googlecode.com/files/jquery.json-2.2.js
- https://getfirebug.com/firebug-lite-debug.js
normalize_css: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment