开发者

Consuming result returned from a form post to a web service

i am calling a web service in this way:

    <form id="test"  method="post"  action="Services/AccessDetails.asmx/getTestData">
    <input type="submit" value="Submit" />
    </开发者_如何学运维form>

and when i submit the button i get the result back in an XML format into a blank page but what i want is to read XML data and consume them in the same page which i placed the above code using javascript (not using helper library like jquery) so my page can be as light as possible


I would suggest to use jQuery for this, something like this should work:

markup:

<form id="testform"  method="post">
  <a href="javascript:;" id="btnSubmit">Submit</a>
</form>

javascript:

$(function(){
  $('#btnSubmit').click(function(e){
    $.post('Services/AccessDetails.asmx/getTestData',
           $("#testform").serialize(), 
           function(data){ /* Code to handle return from the server */;
                           alert("Data Loaded: " + data); }
    );
  });
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜