Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax is eluding me. How to execute a simple ajax request?
    text
    copied!<p>Okay background i am a js and ajax noob. I work mainly in php and mysql html 5, i decided to get with the times and stop having to reload the page for simple things. </p> <p>I am trying to make a simple ajax request to a php file and print the result.</p> <p>So on my page i have a text bax with the id password(leftover from another experiment) a jquery ui tabs setup with a tab with the id galleries and a div with the id my-galleries. The idea is that upon click on the galleries tab the value of the password field is pulled and sent to the php file my-galleries.php and the result is printed to the div my-galleries and displayed.</p> <p>The code:</p> <pre><code>&lt;input type="password" id="password"/&gt; &lt;div id="tabs"&gt; &lt;ul&gt; &lt;li id="welcome"&gt;&lt;a href="content/welcome.html"&gt;Welcome&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="content/about.html"&gt;About&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#my-galleries" id="galleries"&gt;Galleries&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="content/contact.html"&gt;Contact&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div id="my-galleries"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Then the js</p> <pre><code>$("#galleries").click(function(){ $.ajax({ type : 'POST', url : 'my-galleries.php', dataType : 'json', data: { password : $('#password').val() }, success: function(msg){ $("#my-galleries").html(msg) } }) }); </code></pre> <p>Then the php</p> <pre><code>$password= $_REQUEST['password']; $salt= uniqid(); $str= $salt.$password; $hash= hash("sha512", $str); echo $hash; </code></pre> <p>According to the tuts i have been reading it should work but it doesn't. I cant figure it out.</p>
 

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