Jump to content

Escaping ampersands?


woolyg

Recommended Posts

Hi all,

 

I have a piece of code in a file called sajax.php:

 

if(!A && typeof XMLHttpRequest != "undefined")

 

It all works fine, but when I go about debugging and attempting to make the page XHTML-compliant, the '&&' bit gets caught out.

If I replace them with & in each case, the PHP document ceases to function, so I have to revert back to '&&' to get it going again.

 

I have added the following to my php.ini file on the server:

 

arg_separator.output  = "&"

arg_separator.input    = "&"

 

..but it makes no difference.

 

Is there a different way of escaping ampersands so the XHTML inspector will allow them, and for my AJAX to still work?

 

All help much appreciated.

WoolyG

Link to comment
Share on other sites

  • 2 weeks later...

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

/*]]>*/
</script>

 

is the syntax for the CDATA...

 

also you might try separating your javaScript and HTML by putting your javascript in an external file and referencing it :

 


<script type="text/javascript" src="external_javascript_file_name.js"></script>

 

 

Jos.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.