ソース:
<script type="text/javascript">
$(function () {
$("#btn01").click(function () {
$.ajax(
{
async: false,
global: false,
ifModified:false,
url: "/txt/txt1.txt",
cache: false,
beforeSend: function () {
$("#div01").append("<hr/>");
},
dataFilter: function(data, type){
return "<b>" + data + "</b>";
},
success: function (msg, textStatus) {
$("#div01").append(msg + "<br/>");
},
error: function(xhrobj, status, errorEx){
$("#div01").append(status + "<br/>");
},
complete: function (xhrobj, textStatus) {
$("#div01").append(textStatus + "(complete)<hr/>");
}
}
);
});
$("#btn02").click(function () {
$.ajax(
{
type: "post",
url: "/Home/AjaxTest",
cache:false,
dataType: "text", // xml, html, script, json, jsonp, text
data:
{
data: "あいうえお",
data1: ["aaa", "bbb"],
},
success: function (msg, textStatus) {
$("#div02").append("success:<br/>");
$("#div02").append(msg + "<br/>");
var obj = jQuery.parseJSON(msg);
$("#div02").append("obj.a=" + obj.a + ",obj.b=" + obj.b + "<br/>");
},
}
);
});
});
</script>
0 件のコメント:
コメントを投稿