Am I missing something? I'm trying to do a simple ajax call using jquery to a web service on my site and I get a 500 error every time when I make the call from the master page. Has no one ever made an ajax call from a master page or am I just crazy and extremely deprived of sleep?
Example:
MasterPage.master
<script type="text/javascript">
$(document).ready(function () {
$.ajaxSetup({ dataType: "json", contentType: "application/json; charset=utf-8" });
$.ajax({
url: '<%= ResolveUrl("~/Services/Test.asmx/HelloWorld") %>',
success: function (data) {
alert(data);
},
error: function (xhr, err) {
alert("readyState: " + xhr.readyState + "\nstatus: " + xhr.status);
alert("responseText: " + xhr.responseText);
}
});
});
</script>
/Services/Test.asmx
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
See anything wrong? Do I have a misunderstanding of the Master Page? Please help!