asp.net - Ajax response data in .net -
i have asp .net web page , button in it. i'm calling ajax method in button click event follows
$("#btntest").click(function () { $.ajax({ type: 'post', url: 'test2.aspx', success: function (data) { alert( data); }, error: function (data) { alert("in error "); } }); });
in success part alert( data) im getting html code of page test2.aspx (which 1 have given in ajax url).
in test2.aspx.cs code given below
protected void page_load(object sender, eventargs e) { jsontest(); } public list<string> jsontest() { list<string> list = new list<string>(); list.add("aa"); list.add("bb"); list.add("cc"); return list; }
why data in 'list' not coming response data in ajax?
try response.write() method purpose
protected void page_load(object sender, eventargs e) { response.write("data returned"); }
or try write static webmethods in aspx page. methods can call ajax
Comments
Post a Comment