Posts

Showing posts with the label AJAX

"$.ajax is not a function" Error When Using jQuery and Darren Johnstone's ASP.NET Upload/Download Module v2

Lately I've been working with an excellent file upload library for ASP.NET written by a guy named Darren Johnstone. This library allows you to upload files and see a modal dialog and progress bar which indicates the percentage of the file upload having been completed. It doesn't use Flash (or Silverlight for that matter), just good ol' server-side .NET and some AJAX on the client-side. However, it also killed some existing jQuery code I had in place to make some AJAX calls to WCF services. I found I was now getting the following script error: $.ajax is not a function My workaround was to change my jQuery code to not use the $ abbreviation. So, in other words, I changed $.ajax to jQuery.ajax -- then it started working again. I'm not sure what it is about the upload control that affected this, but the workaround is manageable. Now I'll just need to explain to everyone why my code uses the long version instead of the shorter one anytime someone says to me "Hey, ...

jQuery AJAX Calls Not Working In IE8

I recently discovered that some jQuery code I had written for making AJAX calls was not working in IE8, even in Compatibility Mode. Turns out the reason why is that IE8 caches AJAX GET requests. Changing the calls to POST instead of GET corrected the problem. I hope this helps anyone else having this same issue.

Crazy Internal Server Error When Developing With WCF and AJAX with jQuery

I've been doing some development lately involving calling WCF services from client-side script using jQuery's ajax function, and ran into some strange behavior. I had some code written that would run successfully without error, but then added some additional, un-related code, which would also attempt to call a WCF service via jQuery and AJAX. The original, working code remained untouched. The new code would be unsuccessful -- however, the old, previously working code would now also fail. The error was Error 500, Internal Server Error . Stopping and restarting the development server didn't solve the issue, nor did exiting and restarting Visual Studio. Even rebooting my machine didn't help. It just didn't make any sense. I finally resolved the problem by deleting the Temporary ASP.NET files for the site. By default, these are located in C:\WINDOWS\Microsoft.NET\Framework\(Framework Version)\Temporary ASP.NET Files , in a sub-folder matching the name of your site. Not...

How to Update an UpdatePanel Using JavaScript from an IFrame in ASP.NET

I recently had to make some additions to a website I was working on which involved the addition of an AJAX UpdatePanel which would contain a GridView. The GridView would contain rows with information related to submissions we received by the user. A timer would ensure that the GridView would be updated in a timely fashion and reflect any updates in our database, but we also wanted to instantaneously update the GridView as soon as a new submission was received. Updating an UpdatePanel from JavaScript wasn't a problem, but the source of new submissions to the site was located within an IFRAME hosted on the page, not on the page itself. How could I update the UpdatePanel on the main page when the page inside the IFRAME was submitted? Turns out, it's no big deal. All you need to do is add code to the onload event of the IFRAME. This code will call the __doPostBack() JavaScript function that ASP.NET renders when you use the AJAX components. This function takes two parameter...

When AJAX and Forms Authentication Don't Play Nice

I've been doing some work with AJAX in ASP.NET lately, and one of the things I've run into is the "'Sys' is undefined" error. Originally, I was getting this error in my server-side code. You can view my solution in this post . However, once that was resolved, I started getting the same error (or, sometimes, the slightly different "Sys is not defined" -- I think I got this one in FireFox) in my client-side code. The error was occuring on the login page of the site, and the site uses Forms Authentication. It was also intermittent -- everything would be working fine, but then after accessing the page a few times I'd get the error. A quick fix I discovered was to change the authorization info in the web.config file to allow all users, run the app in development mode, then close the browser and change the web.config file back to only allow authenticated users. This would stave off the error for a little while, but it would always return. I fin...

Troubleshooting the "'Sys' is Undefined" Error When Using AJAX Extensions for ASP.NET

If you've put together some ASP.NET code that uses some of the AJAX extensions, but the code doesn't work and you get a client script error that states "'Sys' is undefined", you're not alone. I've experienced this error myself, and none of the stuff I found on the web concerning the error helped me out any. But I was able to resolve the problem, and here's how: I added the following lines to the httpHandlers section of my web.config file. <remove verb="*" path="*.asmx"/> <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicK...