View Single Post
Old April 21st, 2013 (08:38 PM).
droomph's Avatar
mmm gurl that 90s
Community Supporter
Join Date: Sep 2011
Location: bar'jách
Age: 18
Gender: Male
Nature: Impish
Quote originally posted by Archenoth:
The two most common ways to get PHP data into JavaScript is to either:

a) Use AJAX with a PHP file that spits out JSON with json_encode(). For example:
// Some code that sets $var to the desired value or array.
echo json_encode($var);
Then use JSON.parse to parse your JSON into a usable JavaScript variable.

b) Echo JavaScript-usable data into the page... For example:

<script type='text/javascript'>
  var somevar = <?php echo $var; ?>;
Be very careful with this approach though since it is very vulnerable to XSS. (Imagine if $var is set to "4; alert('Hi!');" for example...)

For JavaScript to PHP, since PHP is server-side, this requires server activity. You'll either need to use AJAX or reload your current page with the GET or POST variables you want. GET variables are easy since you can fire an AJAX request to someurl?var=<someval>&anothervar=<someothervar>.
hehe thanks :p that makes it a lot clearer

Soooooooo I'm trying to implement a whissiwig editor or whatever it's called onto my website, and I have with the tinyMCE program…

however one problem is that it takes a long time to load, much worse than the one on PC, but I suppose because it's not WYSIWYG, so…

1) how to make it load faster, or 2) what other better options do I have?

sorry for asking and not telling, but I'm a noob at this :p
did u no there r 21 letters in the alphabet
o i forgot 5