When working with Ajax and get an Ajax Error, the PI Ajax Error Page offers useful information about the Ajax response that caused the error:
Steps to get the information you need:
- Add the url parameter "enabledebugoutput=true" that's "Enable Debug Output = true"
- This outputs the ajax on the page so you can test
- This only works if the code executed successfully but just did not do what you wanted
- In situations where there is an error in the JavaScript code returned in the ajax response, you'll need to disable the redirect to the Ajax Error Page
For Controls
Add the line
#if DEBUG
this.DefaultTemplate.AppendJavaScriptCodeAdditionalOutput("pi.IsDevelopmentMode = true;");
#endif
Page or Back Page
Add the line
#if DEBUG
this.AppendJavaScriptCodeAdditionalOutput("pi.IsDevelopmentMode = true;");
#endif
Notice the above command uses the PI.js file.
If you are not working on PI but are using the MetafuseAjaxPostBack library in that project. Then you can also use:
#if DEBUG
this.AppendJavaScriptCodeAdditionalOutput("UITools.IsDevelopmentMode = true;");
#endif
History Lesson: The #if / #endif are called preprocessors, and they come from the days of C and C++ they allow you to tell the compiler to do things such as build special sections of code if we are compiling for/on a MAC/Linux/Windows or other Device or if this is a DEBUG build or RELEASE build.
The preprocessor above tells the compiler to only build this section of code if the current build is a debug build, if this where a release build than this would be removed from the code entirely.
Adding this to the back page allows you to disable the jump to the Ajax Error Page and view the error directly in the Chrome or what ever JS Debugger you are using.
Click on it, and see where it occurred:
When you click on the expanded line, you'll be brought directly to the code error location.
Comments
0 comments
Please sign in to leave a comment.