Ibid Athoillah Ibid Athoillah - 11 months ago 39
Ajax Question

how to post text '&nsbp ' using javascript?

The content that i want to send

<div id="preview">&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</div>

Element function:

function _(obj) {
return document.getElementById(obj);


type: 'POST',
url: 'http://<?php echo $domain ?>/libraries/ajax/pdf.php',
data: 'html=' + _("preview").innerHTML + '&nama=a',
dataType: 'html',
beforeSend: function() {},
success: function(response) {
Materialize.toast((response), 4000);

How to send
as text instead of

Answer Source

Use the encodeURIComponent(<string to be encoded>) to encode the data