开发者

how to handle response contents by AJAX

for me it seems impossible but expecting clarification on it. i am sending a request as follow :

 <form act开发者_如何学Cion="/name" method="get">
     <input type="text" />
     <input type="submit" />
  </form>

Now action class at server side manipulates & send the response to client, can i handle this response by ajax somehow ??


Yes, but you have to submit it via ajax (XmlHttpRequest) in order to be able to get the response that way.

Using jQuery makes this simple:

$.post("/name", {param:param}, function(data) {

});

In that example you should pass manually each form field as param. In case of bigger forms this is not that good. So you can use serialize():

$.post($("#yourForm").attr("action"),
       $("#yourForm").serialize(),
       responseHandlerFunction);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜