Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Tuesday, August 5, 2014 2:58 PM
I have a webforms project and an mvc controller project. I use the mvc controller project as a service to provide data from the db in JSON format. The mvc controller is working fine and sends out the JSON result (verified in fiddler) but for some reason, why is my success event not firing? The MVC project is deployed as an application in IIS and I have use the URL as my source for the ajax.
$('#ctl00_ctl00_mainbody_topnavigateright_UserStatus_lblUserTagCommentsCount').hover(function () {
$.ajax({
type: "GET",
contentType: 'application/json; charset=utf-8',
url: '<%= Global.WebServiceUrl %>' + '/services/getUserTagsByUserId?userId=113',
dataType: "json",
success: function (data) {
alert('test');
//alert(exists);
} //End Success Function
}); //End Ajax Call
});
All replies (3)
Friday, August 8, 2014 4:24 AM âś…Answered
Hello,
Based on your description, I see your ajax request return data ok but it not call the success function.
For this issue, I think the response not contains a correct json data format however your ajax function expects
a json format data.
dataType: "json",
You can remove above line for a test, and see if your success method called.
Besides, I suggest you add a error callback function to your ajax function and fine what the error is indeed.
$.ajax({
type: "GET",
url: "url",
data: cartObject,
contentType: "application/josn",
dataType: "json",
success: function () {
OnSuccess(cartObject.productID)
},
error: function () {
OnError(cartObject.productID)
},
complete: function () {
// Handle the complete event
alert("ajax completed " + cartObject.productID);
}
}); // end Ajax
Similar issues you can follow below.
http://stackoverflow.com/questions/1969476/ajax-success-event-not-working
http://stackoverflow.com/questions/14475853/jquery-ajax-call-doesnt-call-success-or-error
Thanks.
Best Regards!
Tuesday, August 5, 2014 3:37 PM
Hello,
What error returned from you browser console ?
Tuesday, August 5, 2014 3:53 PM
Hre is what I see in fiddler
GET http://localhost:83//services/getUserTagsByUserId?userId=113 HTTP/1.1
Host: localhost:83
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://localhost:12577/profile/profile.aspx
Origin: http://localhost:12577
Connection: keep-alive
RESULT:
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNetMvc-Version: 4.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Tue, 05 Aug 2014 19:52:05 GMT
Content-Length: 613
... MY JSON RESULT HERE ...