1

In my HTML file I have the following code at the end:

<script type="text/javascript">
  function voteUp(userID,userName,channelID,messageID,voteUp,voteDown)
  {
    $.get("_vote/vote_ajax.php?userID="+userID+"&userName="+userName+"&channelID="+channelID+"&messageID="+messageID+"&voteUp="+voteUp+"&voteDown="+voteDown, function(response){
       // alert("Data: " + data + "\nStatus: " + status);
       alert(response);
    });
  } 
</script>

But I have error when I load the HTML page:

XML Parsing Error: not well-formed Location: http://localhost/ajaxChat/ Line Number 626, Column 55: $.get("_vote/vote_ajax.php?userID="+userID+"&userName="+userName+"&channelID="+channelID+"&messageID="+messageID+"&voteUp="+voteUp+"&voteDown="+voteDown, function(response){ -------------------------------------------------------------^

If I use only one parameter, the HTML page is loading properly:

<script type="text/javascript">
  function voteUp(userID,userName,channelID,messageID,voteUp,voteDown)
  {
    $.get("_vote/vote_ajax.php?userID="+userID, function(response){
       // alert("Data: " + data + "\nStatus: " + status);
       alert(response);
    });
  } 
</script>
Mario Ene
  • 843
  • 1
  • 10
  • 22

2 Answers2

2

Your page is running through an XML parser so looks like you need to add a CDATA block

<script type="text/javascript">
/* <![CDATA[ */
  function voteUp(userID,userName,channelID,messageID,voteUp,voteDown) {
    $.get("_vote/vote_ajax.php?userID="+userID+"&userName="+userName+"&channelID="+channelID+"&messageID="+messageID+"&voteUp="+voteUp+"&voteDown="+voteDown, function(response){
       // alert("Data: " + data + "\nStatus: " + status);
       alert(response);
    });
  } 
/* ]]> */
</script>
epascarello
  • 204,599
  • 20
  • 195
  • 236
0

Ok, I've had this problem when using links with multiple parameters in Blogger templates, for example, where they go trough an XML parser.

What you have to do is replace the "&" for "&amp;".

That's it!

 $.get("_vote/vote_ajax.php?userID="+userID+"&amp;userName="+userName+"&amp;channelID="+channelID+"&amp;messageID="+messageID+"&amp;voteUp="+voteUp+"&amp;voteDown="+voteDown, function(response){ ...
Juan Bonnett
  • 1,823
  • 1
  • 15
  • 33