encode_query function helper

string encode_query(q)

This helper function used to encodes POST-data with encodeURIComponent() function and place into data as Form Data Parameter | Form Data Parameter access example (php): rawurldecode($_POST['data']). Encoding useful for JSONs.

  • q - string / JSON | Value to encode

Full function:

function encode_query(q){
	console.log('RUN encode_query() function');
	q = eval('(' + q + ')');
	q = JSON.stringify(q);
	q = q.replace(/\n/g, '<br>');
	q = 'data='+encodeURIComponent(q);
	return q;