Showing posts with label AJAX. Show all posts
Showing posts with label AJAX. Show all posts

Monday, 12 December 2011

Cannot read JSON object property - MVC AJAX

If you're ever banging your head against a brick wall trying to figure out why your javascript code is returning 'undefined' when you attempt to 'alert()' a JSON object property...particuarly if you know that the server is returning an error code, try inspecting the the JSON object via 'responseText'

eg JSON: { "propertyName" : "propertyValue" }

Instead of accessing the property like:

alert(propertyName.propertyValue);

Try:

alert(responseText.propertyName.propertyValue);

The reason for this is: [google "can't access JSON object responseText"]

Sunday, 4 September 2011

ASP.Net AJAX Still Suffers from ASP.NET ViewstateWeight

Even though bandwidth-heavy page updating is one of the main problems that Ajax is supposed to solve, ASP.Net AJAX still has to send the entire page's ViewState data back and forth in each asynchronous request!

Wednesday, 31 August 2011

ClientScriptManager - Where does it insert the Javascript???

There are various options available.

You can add a script block at the top of the rendered page, using the method:

ClientScriptManager.RegisterClientScriptInclude(string key, string url)

When accessing compiled-in resources from assemblies through the WebResource.axd HTTP handler, you can wrap the contents of the resource URL with a <script> element block, using the method:

ClientScriptManager.RegisterClientScriptResource(Type type, string resourceName)