homepage Welcome to WebmasterWorld Guest from 23.22.97.26
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Ajax not working in firefox when DOCTYPE is added
mini




msg:3811828
 11:36 am on Dec 20, 2008 (gmt 0)

Hi,

When I add the DOCTYPE, ajax is not working in Mozilla firefox though it works in Internet Explorer. What can be done in this case? I just want to make my code w3c compliant.

This code works fine (in both IE and firefox):

<html>
<head>
<title><?php echo $title;?></title>
<meta name="robots" content="all,index,follow"/>
<meta name="description" content="<?php echo $description;?>"/>
<meta name="keywords" content="<?php echo $keywords;?>"/>
<meta name="classification" content="hotels,resorts"/>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<style type="text/css">
<!--
body {
background-color: #666666;
margin:0;
padding:0;
}
-->
</style>
<link href="style.css" rel="stylesheet" type="text/css"/>
</head>
..........

But this code does not work in firefox but works in IE:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo $title;?></title>
<meta name="robots" content="all,index,follow"/>
<meta name="description" content="<?php echo $description;?>"/>
<meta name="keywords" content="<?php echo $keywords;?>"/>
<meta name="classification" content="hotels,resorts"/>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<style type="text/css">
<!--
body {
background-color: #666666;
margin:0;
padding:0;
}
-->
</style>
<link href="style.css" rel="stylesheet" type="text/css"/>
</head>
..........

 

coopster




msg:3811854
 1:26 pm on Dec 20, 2008 (gmt 0)

What can be done in this case? I just want to make my code w3c compliant.

How do you know it is not compliant? If you tested it against the validator [validator.w3.org], what did it tell you?

I would start there.

mini




msg:3812561
 4:38 am on Dec 22, 2008 (gmt 0)

For a code to be W3C compliant, it must have the DOCTYPE. If I don't mention the DOCTYPE, the validator gives 9 errors and 62 warnings.

Errors:

Line 1, Column 0: no document type declaration; implying "<!DOCTYPE HTML SYSTEM>".
Line 5, Column 252: document type does not allow element "META" here.
Line 6, Column 161: document type does not allow element "META" here.
Line 7, Column 109: document type does not allow element "META" here.
Line 8, Column 71: document type does not allow element "META" here.
Line 9, Column 22: document type does not allow element "STYLE" here.
Line 19, Column 56: document type does not allow element "LINK" here.
Line 56, Column 6: end tag for element "HEAD" which is not open.
Line 57, Column 5: document type does not allow element "BODY" here.

One of the warnings:
Line 4, Column 46: NET-enabling start-tag requires SHORTTAG YES.

mini




msg:3812572
 5:46 am on Dec 22, 2008 (gmt 0)

:(

coopster




msg:3812915
 6:21 pm on Dec 22, 2008 (gmt 0)

If you attempt to validate the source code like that you are going to get errors on the <?php ?> tags. You need to let your server render the code, view source in the browser, and copy/paste the rendered code into the validator. Or just give the validator the URI and it will retrieve the rendered source for validation.

You mention that if you leave the DOCTYPE it will indeed validate, but your AJAX won't function properly ... yet you have not shown any JavaScript here at all. The likely issue is that you are using properties or methods in the JavaScript code that are not recognized by the Gecko engine.

mini




msg:3813204
 6:15 am on Dec 23, 2008 (gmt 0)

Its the reverse: If I leave the doctype, ajax works but the code is not W3C compliant. If I include the doctype, the code becomes W3C compliant but ajax does not work.

I have put here the php code by mistake.I do it the way you have mentioned, that is, by using the resultant html given by the browser.

I sent you a sticky mail yesterday wherein I included the javascript and the actual problem. It seems you have not received it. Please check if you have got my mail or not. Thanks...

coopster




msg:3813327
 1:06 pm on Dec 23, 2008 (gmt 0)

I did indeed receive the stickymail but prefer to keep the discussion in the public forum. Stickymail doesn't contribute to the discussion and future readers will never know how to resolve the issue if they cannot read about it. Also, you'll get much more analysis with more eyes viewing the problem. If the code is too personal/protected, you may need to hire the job out.

astupidname




msg:3813393
 3:40 pm on Dec 23, 2008 (gmt 0)

As coopster points out, you have not shown any javascript here. Just a shot in the dark then. If you have any script tags which contain javascript code on an xhtml page, you need to use CDATA tags inside the script tags, in order to validate. Are you currently doing so? CDATA tags are not needed if the script tags are just a link to an external .js file, just to clarify that.

<script type="text/javascript">
/*<![CDATA[*/

//...javascript code in here...

/*]]>*/
</script>

As I said, just a shot in the dark...

mini




msg:3815402
 5:32 am on Dec 29, 2008 (gmt 0)

Astupidname, using CDATA tags also did not solve the problem. But your reply is quite informative and it added to my knowledge. Thanks.

Coopster, I understand your point. Let me work on this for sometime and I will revert if needed. Thanks...

two4god07




msg:3817606
 2:57 am on Jan 2, 2009 (gmt 0)

I just downloaded firefox last week because the youth pastor at the church kept telling me my formats weren't working when he loaded the page, but I saw everything just fine. It turned out he had firefox, and I missed a couple of things that would have made my entire page xhtml compliant. It wasn't even things that would affect the formatting.

Once I got everything follwing xhtml rules, the formats I made began to work.

I guess it's because how standardized firefox is.

Maybe look over your entire document for small errors that you could have missed?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved