javascript - How to pass data to AJAX call -
can tell me how pass data jsp making ajax call ? trying:
here ajax call:
$.get("gridedit.jsp", { before: "row", time: "2pm" }) .done(function(data) { alert("data loaded: " + data); });
here gridedit.jsp
<% string b=request.getparameter("before"); if(b.equalsignorecase("row")) { system.out.println("row row row boat"); out.println("bummer"); } %>
i want store value returned gridedit.jsp javascript variable. how should ?
please help
thanks
edit:
here tried
$.ajax({ url: "gridedit.jsp", async: true, cache: false, type:"get", data: { before:'row', }, error: function(msg) { alert(msg); }, complete: function (xhr, status) { alert('complete: '+status); } });
i 2 alerts, first 1 says
[object][object]
and second 1 says
error
can figure out whats going on ?
please help
thanks
errors;
so here tried
$.ajax({ url: "gridedit.jsp", //datatype: "json", async: true, cache: false, type:"get", data: { before:'row' }, error: function( jqxhr, textstatus, errorthrown ) { alert(jqxhr); alert(textstatus); alert(errorthrown);}, complete: function (xhr, status) { alert('jqxhr:'+xhr); alert('complete: '+status); } });
i following alerts in order:
jqxhr: [object][object]
teststatus:
parseerror
errorthrown:
unexpected end of input
can please me in solving ? gridedit.jsp this->
<%string b=request.getparameter("before"); system.out.println("b here !" + b); out.println("hello");%>
please help
thanks
try number two:
i have ajax request looks this:
$.ajax({ url: "/someplace", datatype: "json", async: true, cache: false, data: { number0: 0, key: littlekey }, success: function(data, status) { alert(data); } });
and works expected.
and can specify type : "get"
in other options.
maybe try having .jsp print data no matter what, , print data receiving.
Comments
Post a Comment