Jump to content
xisto Community
Sign in to follow this  
sonesay

Problems With Trying To Validate Ajax Called Html

Recommended Posts

I've been validating my site on http://validator.w3.org/ so far so good but what I'm interested in is validating my page that has been modified by Ajax requests. Viewing the source code afterwards wont show the new code in Firefox and its the same for other browsers I believe(yes I have tried and cant remember ever seeing the newly inserted HTML in the source code).

I'm certain my code is not going to be valid there because I've hacked away at getting it to work and its very long so there are bound to be mistakes hence the reason why I would want to validate it. Are there any methods for checking it beside the obvious copy and paste each section of the Ajax request responses in to the direct input textarea provided by W3. Its going to be very tedious this way and if thats the only way I do not think I will bother just yet. At-least it works right :o and no one will ever see the source code unless they have the PHP files.

Share this post


Link to post
Share on other sites

You can't see the manipulated code after AJAX calls as the browsers make changes to the Document Object Model and render the changes. I'm not sure but DOM viewers might help you. Free DOM viewers are available for both IE & Firefox.

Share this post


Link to post
Share on other sites

There are two ways to do it

you can use web developer plugin for firefox which allows you to see generated source code,

you can download it here https://addons.mozilla.org/en-US/firefox/addon/web-developer/

you can use php function htmlentities() to print the output and validate it with dreamweaver

Here are some problems with the first suggestion.

 

Using 'View Generated Source' removes the DOCTYPE from the code that it displays, and converts self closing tags to invalid, unclosed tags.

 

For example, the standard 'View Source' displays this at the top:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://forums.xisto.com/no_longer_exists/">

<html xmlns="http://forums.xisto.com/no_longer_exists/" xml:lang="en" lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

'View Generated Source' for the same page displays this at the top:

 

<html xml:lang="en" xmlns="http://forums.xisto.com/no_longer_exists/" lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

 

Other self closing tags such as "br", "img", "input" are reported as ..'end tag omitted..'.

 

I'm not sure how to use htmlentities() to output the entire source of a dynamically generated page. Eclipse seems to be working on component to address this issue. http://forums.xisto.com/no_longer_exists/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.