Thanks all for the help, rod.
Hi All,
Is it possible to call a web service (on my localhost) from jquery in a plain html page inside an asp.net 2.0 webform application using visual studio 2005?
<script type="text/javascript">
$(document).ready(function(){
$('#button1').click(function(){
$('#targetDiv').load('http://localhost/testservice/Service1.asmx/HelloWorld',null,function(){alert('test')});
});
});
</script>
I’m getting a 500 error? Not sure if it’s even possible to do this way?
thanks,
rod
By default, ASP.Net doesn’t enable web methods for
GETrequests (which is what a data-less.load()does). Scott Guthrie has a nice blog post on how to enable GET on Web Methods.However, keep in mind that they’re disabled for a reason (security mainly), you may want to just use a
$.post()instead, like this:Or make
.load()trigger POST with a dummy data object, like this:The
{}is the key, passing an object makes.load()do aPOSTinstead of aGET.