Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Firstly, If you use the button tag inside the html form browser may interpret as the submit request. Which is why you do a button press with the form its no more an ajax request. Which could be noted when you render the homepage the url would be something like localhost:8000/home but after the button click url would be localhost:8000/home? which denotes there was a normal get request</p> <p>If you still want the button to create a ajax request inside the form do something like this:</p> <pre><code> &lt;script type="text/javascript"&gt; $(function(){ $('button').click(function(e){ e.preventDefault(); doAjax(); }) }) function doAjax() { alert('yes'); $.ajax({ url: '/register/', data: ({name : "me"}), success: function(data) { $('#time').html(data); } }); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form action=""&gt; &lt;button id="demo" title="Button"&gt;Get the time!&lt;/button&gt; &lt;/form&gt; &lt;div id="time"&gt; &lt;/div&gt; </code></pre> <p>Secondly, try changing the url in your Ajax function to "/register.html/". Mind the slashes. Since it could be possible in some cases where jquery would suggest append the given url to the page's url. </p> <p>For example, if your page url is localhost:8000/home. The request generated could be localhost:8000/home/register. So, its always a good idea to use slashes when you define your urls.</p> <p>Laslty, try using some other extension instead of html since, html is conventionally used to generate static content and convent for dynamic content is htm. Its just a convention for a good practice rest is your choice.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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