I have this code, but this line has some problem.
var dataString = 'name='+name&'id='+id;
what is sent (firebug):
'id ' id
'name' name
The line above works correctly if i do: var dataString = 'name='+name;
However, i need to pass two parameters. What is the correct way to do that?
code
<script type="text/javascript">
$(function () {
$(".vote").click(function () {
var id = $(this).attr("id");
var name = $(this).attr("name");
var dataString = 'name='+name&'id='+id;
if (name == 'up') {
$.ajax({
type: "POST",
url: "url.php",
data: dataString,
cache: false,
success: function (html) {
}
});
return false;
});
});
</script>
You should do:
instead of
So that you are sure that the supplied values are correctly URI encoded.