Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think There is a bit of a mixup. A lot of developers do not understand at first that javascript is rendered on client side, while the template ( in your case the php code ) is rendered in server side. </p> <p>What does it mean?</p> <p>It means that the server is running php code that outputs and HTML string to the browser. This HTML string contains script segments with javascript. Once the php code is done, the code leaves the server and travels through the network to the browser. Once it gets to the browser, the browser has no knowledge oh which code generated the HTML. It just as well could have been a static resource. </p> <p>In order to run php code on user input, the user input must travel back to the server. And in order to show any code output to the user, the output must travel back from the server to the browser. </p> <p>This round-trip is done in one of two ways. The first is forms, which refreshes the entire page ( not suitable for this case. ) The other is AJAX. </p> <p>AJAX is a way to send small pieces of information to the server, render them on server side, and get them back after rendering into a javascript function. It's kind of like turning the textarea input to a "php string". What will actually happen is - you will send the text area input to the server, the server will render a php template ( in which it will simply operate the "mysql_real_escape_string" function on the data ) , the rendered result will get back to a javascript callback, and then you can please it in the "preview" div.</p> <p><a href="http://www.queness.com/post/328/a-simple-ajax-driven-website-with-jqueryphp" rel="nofollow">Here a cool tutorial</a> I found about ajax and php using jquery. ( use jquery )</p> <p>Hope this helps.</p> <p>The javaspcript code should look something like the following</p> <pre><code>$.ajax({ 'url' : '/render-string-for-preview', 'type':'post', 'data' : { 'text' : $("textarea").val() }, 'success' : function(result) { $("#input_excercise").html( result ) } }); </code></pre> <p>And you should add a resource on "/render-string-for-preview" which will simply do something like ( not a php developer ... ) </p> <pre><code> &lt;? mysql_real_escape_string ( POST["text"]) ?&gt; </code></pre> <p>And that's it.... </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload