Tuesday, 6 August 2013

On what circumstances should we NOT use php inside javascript?

On what circumstances should we NOT use php inside javascript?

$('#tip2').qtip({
content: {
text: '<?php echo "I do work."?>'
},
In this case I'm using a jquery plugin but that doesn't matter for the
question I believe.
I thought I had to go trough json calls (or other ajax call methods)
because php runs first, and only later runs javascript, but, I actually
tested this code, and it actually displays the text.
Can anyone please take some words to explain, on what circumstances should
we NOT use php inside javascript. Is this one of them? If so, why?
I'm clearly not getting some client side, and server side workflow...
please forgive my newbielity towards those matters.
Sorry if this was an inconvenient question.

No comments:

Post a Comment