ajax saving textarea

ricslabb03

Member
Hi guys,

I am trying to save a textarea at the click of a button using element js. However the textarea contains quotes and single quotes. What is correct way to this?

I realize that this is a general js question, but the answers online use jquery and since element js uses mootools it has been difficult to find an answer that works.

Here is my code for reference:

JavaScript:
var form = Fabrik.getBlock('form_32');
var message = form.elements.get('emaillist___emailmessage').get('value');
var subject = form.elements.get('emaillist___subject').get('value');
var clientid = form.elements.get('emaillist___clientid').get('value');
var templateid = form.elements.get('emaillist___template_id');

var message = JSON.stringify(message);
var url = 'my/file/path/settemplate.php';

var params = 'subj='+subject+'&cid='+clientid+'&msg='+message;

var myHTMLRequest = new Request.HTML({
  url: url,
  onComplete: function(response) {
    var obj = JSON.parse(response);
    alert(obj.message);
  }
}).post(params);
 
You can use jQuery. We use both, liberally. Just use jQuery() instead of $().

But I'm not entirely sure why you are stringify'ing the message, which is where I assume the problem with quotes occurs. You should just be able to use encodeUri().

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top