I have this code, but this line has some problems.
var dataString = 'name='+name&'id='+id;
what 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 right way to do this?
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>
source share