Submit Django search form and use .jquery .load for the results?
NickName:user3199840 Ask DateTime:2014-03-01T08:06:49

Submit Django search form and use .jquery .load for the results?

I'm building a search function with Jquery and Django. And Im wondering how I combine the jquery .load function with a form submit.

This is what im working with.

I click a link which open a dialog box, loads a child template with a Django form for search.

    <form method="post" id="searchform" action="/search/">{% csrf_token %}
    {{ form.as_p }}
    <button type="submit" id="submitsearch">Search</button><p>
    </form>

This function works great if i just redirect to a new page with the search results that i get back from my Django view when the form is handled.

But when the searchform is filled i want to submit and get the results back in the same dialog. I'm thinking something like this (but this is not working)...

    $("#dialog").on("click", "#submitsearch", function(event) {
      event.preventDefault();
      $("#dialog").load('search/' + $('#searchform').serialize());

Is it possible to use the ".load" into the dialog and submit the form at the same time? How?

Thanks!

Copyright Notice:Content Author:「user3199840」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/22108177/submit-django-search-form-and-use-jquery-load-for-the-results

More about “Submit Django search form and use .jquery .load for the results?” related questions

Submit Django search form and use .jquery .load for the results?

I'm building a search function with Jquery and Django. And Im wondering how I combine the jquery .load function with a form submit. This is what im working with. I click a link which open a dialo...

Show Detail

load search results into a div jquery and rails

In my rails app I have a search bar where users can search other users. Currently when a User submits the search from, they're redirected to a "results" page. I want to load those results in a div ...

Show Detail

Load search form results inline with jQuery, instead of on a new page

I'm trying to build a custom search form for an e-commerce setup built on Magento. This search form consists of several (dropdown) select boxes. The form is functioning properly, but after you cho...

Show Detail

load django form template with Jquery

I want to load a form of a django template in a Jquery popup. The form loads fine in the popup's div but when i click submit nothing happens. The form itself seems to work on it's own url but not i...

Show Detail

Jquery(ajax) PHP search results not displaying in search_results div under form

For a website I'm making for school, I'm trying my hand at using Jquery extensively for the first time, and even though I managed quite a bit so far, I'm stuck at two (most likely related) problems...

Show Detail

jQuery - reset form after submit w/ form plugin

let me start by saying it may look simple but im finding it extremely difficult. ive made a search script that uses PHP and to fetch a result would look like this search.php?term=alice&amp;submit=

Show Detail

trigger form submit after changing a form value in jquery

When I click the Next Page button (marked as >> in form), I am able to change the value of the form input in jquery. But am unable to get the Form Submit to be called after that. I have tried the

Show Detail

Ruby on rails - Load more button with kaminari and search form. Jquery problems

I have an ajax search form and ajax pagination using kaminari. I would like to change this into a 'load more' button but I'm having trouble with the jquery. For the form and normal pagination I was

Show Detail

Redirection on form submit in django with javascript (jquery)

i don't understand why this redirect is happening basically in my html i have a textinput field with id of id_location a form with id of user_form and a submit button for the form with id submit_fo...

Show Detail

Search paginated results with jQuery

I have developed a single page app that shows all the entries off a database table. The results are paginated and are presented without refreshing the whole page. The html part of my code is this: ...

Show Detail