Posts Tagged ‘JavaScript’
Global AJAX Request Error Display for Asp.net MVC 2
So you thought you might like to,
Go to the show.
To feel the warm thrill of confusion,
That space cadet glow.
Tell me is something eluding you, sunshine?
Is this not what you expected to see?
Ever get that kind of feeling when trying to debug server side request errors using AJAX (MS AJAX or jQuery) in MVC. I mean, on a normal posts that fails you get the nice yellow error screen that says “Hey you …” and “Bring on the (Stack Trace)!” and makes your wonder “Is there anybody out there?”. We’ll no more. Here’s a basic script you can just hook up while building/debugging your app that if you get a server side error making an AJAX request you’ll get the same effect as a full post back.
/// <reference path="../Common/MicrosoftAjax.js" />
$(document).ready(function () {
//replace the screen with the response error
//jQuery —————————————————–
$(document).ajaxError(function (event, request, settings) {
$(document.body).html(request.responseText);
});
//MS AJAX —————————————————-
function OnWebRequestComplete(executor, eventArgs) {
if (executor.get_statusCode() === 500) {
$(document.body).html(executor.get_responseData());
}
}
Sys.Net.WebRequestManager.add_completedRequest(OnWebRequestComplete);
});
Visual Studio 2010 RC – Problem with parseInt/parseFloat when Using JavaScript Intellisense
Posted on Connect, but I wanted to see if anyone else had this problem. Here’s the description:
When using a call to ‘parseInt’ or ‘parseFloat’ methods intellisense will become slow, and in the case of jQuery methods not work at all. Commenting out or removing the ‘parseInt’ and/or ‘parseFloat’ call resolves the issue.
Here is the code sample that busts:
- /// <reference path="jquery-1.3.2-vsdoc.js" />
- $(document).ready(function () {
- //due to parseInt or parseFloat being called intellisense will slow or not work
- //if both are commented out it will work properly, if one if called it slows or breaks
- var result1 = parseInt("10", 10);
- var result2 = parseFloat("10");
- //try using intellisense below this comment – it is very slow
- });
If it fails for you too, then follow this link to Connect and confirm. The VS 2010 JavaScript intellisense is great, and we want to help get as many bugs stomped out before the final release.