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); }
);
});
});
精彩评论