tags:

views:

14

answers:

2

ajax code-

...  
xmlhttp.open("GET","voting.php?qid="+qid+", uid="+uid+", type="+type,true);
...

is this the correct way to sent three parameters??

html-

<td ><img src="images/up.jpeg" style="border:none;" title="Like" onclick="doVote($q_id,$_SESSION['UserId'],up)"></td>

when I am clicking on this image ajax script is not working.where should I fire onclick function???

A: 

The character separating parameters is usually & (though you might add/change characters that php will recognize as separators via arg_separator.input). You also should ensure that the parameters are properly encoded, e.g. via escape().

xmlhttp.open("GET","voting.php?qid="+escape(qid)+"&uid="+escape(uid)+"&type="+escape(type),true);
VolkerK
+3  A: 

Three mistakes:

  • The correct notation for multiple GET parameters is separating them by & or, if used in HTML source, the correct HTML entity &amp;

    "voting.php?qid="+qid+"&amp;uid="+uid+"&amp;type="+type
    
  • To output a PHP variable, you need to wrap them around PHP tags:

    "doVote('<?php echo $q_id; ?>','<?php echo $_SESSION['UserId']; ?>',up)"
    
  • The third parameter to doVote(), "up", needs to be enclosed in quotes if it's meant to be a string:

     ..., 'up');
    

other than that, the onclick event should fire. Check your error console for any errors.

Pekka