Featured post
jquery - ajax post method not working in vb.net -
i using jquery using ajax post data, reason when click on submit, page doesnt go aspx aspx.vb on side. here's code -
$(document).ready(function() { $("#btnsave").click(function() { var firstname = $("#" + '<%=firstname.clientid%>').val(); $.ajax({ type: "post", url: "student.aspx/new_class", data: "firstname="+ firstname + ";", contenttype: "application/json; charset=utf-8", datatype: "json", success: function() { } }); }); });
new_class webmethod in vb.net side. if put alert in btnsave onclick function, see firstname value in alert. page not call new_class function after that. ideas i'm going wrong?
that url incorrect mapping method on server-side code.
i assume you're trying call method called new_class
in student.aspx.vb
. correct?
what you'll want create separate page request. maybe student_ajax.aspx
or of nature. how organize you. simplest way go doing you're trying have new_class
logic page_load
logic in new page. in method you'll generate json (which i'm assuming you're doing manually , correctly, that's different question if comes up) return client.
note, however, in page you'll need trickery. first, rid of of html in page itself. want return only json, not wrapped in html. then, when you're generating response string in code-behind logic, you'll want set header proper headers , output string:
response.clear() response.contenttype = "application/json" response.write(myjsonstring) response.end()
note freehand, there may detail or 2 missing in implementation. , know there more elegant ways this. i'm sure can find tutorial or 2 on google. you're trying create custom handler on server ajax request returns json data.
- Get link
- X
- Other Apps
Comments
Post a Comment