I am a total newbie to ASP.net, javascript, jquery, ajax etc. I used to be a WPF programmer but have been handed a web app to write (my first) and am facing a lot of problems. I have jquery/ajax call I have to make to connect to a WCF JSON REST service (tested with Fiddler). The service works fine but I am unable to connect to the service via the jquery. I seem unable to debug it either (I'm used to straightforward debugging in C#, how do you debug this?? I did try that in chrome tools->developer tools and it appeared like it wasn't entering the $.ajax section, but I am not sure if my results were accurate).
Also, what libraries/other setup do you need for jquery/ajax to work?
This is my input button:" "
<script type="text/javascript">
function POSTMethodCall() {
alert("entered function");
debugger;
$.ajax({
type: "GET",
url: "http://localhost:1282/DispatchAcceptStatsService.svc/GetStr",
// data: JSON.stringify(),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
alert("entered success function");
},
error: {alert:"entered error function"}
});
}
</script>
UPDATE: I think I managed to get it to break at that error statement. Here is a copy of the "watch window" for response. The responseText appears to be blank though. proto: function Empty() {} readyState: 0 responseText: "" setRequestHeader: function ( name, value ) { state: function () { status: 0 statusCode: function ( map ) { statusText: "error" success: function () { then: function ( doneCallbacks, failCallbacks, progressCallbacks ) { proto: Object – Tanuj Oruganti 22 mins ago
However these are the contents of the console window: event.returnValue is deprecated. Please use the standard event.preventDefault() instead. jquery-1.7.1.js:3445 OPTIONS localhost:1282/DispatchAcceptStatsService.svc/GetStr 405 (Method Not Allowed) jquery-1.7.1.js:8102 XMLHttpRequest cannot load localhost:1282/DispatchAcceptStatsService.svc/GetStr. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost:62175'; is therefore not allowed access. Submit:1 – Tanuj Oruganti 2 mins ago edit