Note that there are some explanatory texts on larger screens.

plurals
  1. POEmbedding PHP within AJAX
    primarykey
    data
    text
    <p>First of all, let me supply what I'm disposing with in this scenario:</p> <p><strong>index.php</strong></p> <pre><code>&lt;script text='type/javascript'&gt; $(document).ready(function(){ $('#load').click(load); }); function load(){ $.ajax({ data:&lt;?php header('HTTP/1.0 404 Not Found');echo 'Ok'; ?&gt; }).done(function(data){ $('#content').append(data); } } &lt;/script&gt; &lt;select id='load'&gt; &lt;option value='1'&gt;1&lt;/option&gt; &lt;/select&gt; </code></pre> <p>I need whenever the select menu is clicked, a PHP code snippet to be executed. In this case let's I need the string <strong><em>'Ok'</em></strong> to be executed (just an example so as to see how it would work). However I'm not quite confident as far as Ajax is concerned but I'm certain the following is the issue:</p> <pre><code>data:&lt;?php header('HTTP/1.0 404 Not Found');echo 'Ok'; ?&gt; </code></pre> <p>I do not prefer to use <strong>url:''</strong> and redirect to a page where the PHP I want to execute is located. I need it all in the <strong><em>index.php</em></strong> file. As well as that I expect this to be done with Ajax because I need the requests being asynchronous so that the page won't be refreshed.</p> <p>In fact I'm developing a database modifier and I need to list all tables from a corresponding database and I need to validate that through Ajax as you might guess. So I need whenever a database has been chosen to list the tables from within it. I'm posting all this in case it may help.</p> <p><img src="https://i.stack.imgur.com/h765b.png" alt="Code structure"></p> <p><em>Thank you in advance for any answers and possible solutions!</em></p>
    singulars
    1. This table or related slice is empty.
    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.
 

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