Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere should I host php file for ajax call?
    primarykey
    data
    text
    <p>So I have a very simple request. I am trying to make a call using jQuery to a php file so that the file's response will be put into a "div". I know there are other posts but for some reason none of them seem to be working for me.</p> <p>Here is my code:</p> <p><strong>gettable.php</strong></p> <pre><code>&lt;?php echo "&lt;p&gt;Great-Success&lt;/p&gt;"; ?&gt; </code></pre> <p><strong>sequencingfile.html</strong></p> <pre><code>jQuery("#tableHolder").load("/path/to/php-file/gettable.php", function(response, status, xhr) { alert(response); alert(status); alert(xhr); if (status == "error") { console.log(msg + xhr.status + " " + xhr.statusText); } }); </code></pre> <p><strong>Notes</strong></p> <ul> <li><p>The contents of the div changes to this:</p> <p>Great-Success</p> <p>"; ?></p></li> <li><p>The html code is run after you click a button</p></li> <li>The div which I am trying to load the echo from the php call has id "tableHolder".</li> <li>I am running this on the firefox, it doesn't work on chrome at all.</li> <li>The response is the actual contents of the php file itself.</li> <li>The status is "success".</li> <li><p>The xhr is "[object Object]"</p></li> <li><p>Eventually I am trying to call the php file to query from a mysql database to create a table(if you know of a better and more efficient way of doing this please let me know), but for now all I want is the echo of the php call to come back and be put into the div as it should.</p></li> <li>The file is set locally</li> <li>The computer is linux</li> <li>That's all the detail I can think of, please let me know if you need any more details</li> </ul> <p><strong>EDIT</strong></p> <p>Alright I have set up an apache server and changed the link to <code>http://127.0.0.1/gettable.php</code> and it still doesn't work. When I type that url into firefox or chrome it works, but not when I run the html file. What am I doing wrong?</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.
    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