HTML page
// in script tag
$(document).ready(function () {
var url = "list.ashx";
$.get(url + "?get", function (r1) { alert("get: " + r1); });
$.post(url + "?post", function (r2) { alert("post: " + r2); });
$.ajax(url + "?ajax", function (r3) { alert("ajax: " + r3); });
$("div:last").load(url + "?load", function (r4) { alert("load: " + r4); });
});
// in body tag
<div></div>
in 'list.ashx'
public void ProcessRequest (HttpContext context) { context.Response.Write("ok"); }
the result
- $.get and $.post reach list.ashx but no return
- $.ajax not reach list.ashx
- $.load fully success
The problems are
- why only '$.load' work?
- how to make $.get or $.post work?
update
$("input").click(function () {
$.ajax({ url: url
, context: this
, data: "ajax=test"
, cache: false
, async: false
, global: false
, type:"POST"
, processData: false
, dataType: "html"
, success: function (data) { alert(data); }
, error: function (data) { alert(data.responseText); }
});
});
it's always hit error:function(){} but the 'data.responseText' is the correct result!!