<script type="text/javascript">
$(".commentPost").live('click',function() {
var expressID = $(this).attr('id');
var comment = $("#getComment"+expressID).attr('value');
//If comment contains & then how to pass it in URL??
$.get('../addons/comment.jsp?comment='+comment+'&expressID='+expressID, function(data) {
$('#commentBlock'+expressID).append(data);
$("#getComment"+expressID).attr('value','');
});
});
</script>
Please tell me how to pass & as text in URL. And how to replace it using jQuery.
Use the second argument to pass a data hash. This way jQuery will take care of properly url encoding: