Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango Ajax Jquery Call
    primarykey
    data
    text
    <p>This may be basic, but I've spent two days, read countless tutorials and I still can not get this to work. For simplicitly I tried to accomplish a basic task just to see it work. I want to send make an ajax call to my donate view. I see that it successfully passes through but I was expecting that my template would also get updated to "TRUE" but it remains "FALSE". Any help or suggestions I appreciate. </p> <p>my jquery...</p> <pre><code>$.ajax({ type: "POST", url:"/donate/", data: { 'test': 'success', }, success: function(){ alert('test') }, error: function(){ alert("Error"); }); </code></pre> <p>this is my view... </p> <pre><code>def donate(request): if request.is_ajax(): test = "TRUE" if request.method == 'POST': form = DonateForm(request.POST) if form.is_valid(): form.save() else: form = DonateForm() test = "FALSE" return render_to_response('donate_form.html', {'form':form,'test':test}, context_instance=RequestContext(request)) </code></pre> <p>my template include this...</p> <pre><code>&lt;h1&gt;{{ test }}&lt;/h1&gt; </code></pre> <h2>Update/Solution</h2> <p>Like mentioned in the comments on this question, I was not doing anything the the returned data. I updated my success call to the following and it worked </p> <pre><code> $.ajax({ type: "POST", url:"/donate/", data: { 'zip': zip, }, success: function(data){ results = $(data).find('#results').html() $("#id_date").replaceWith("&lt;span&gt;" + results + "&lt;/span &gt;"); }, error: function(){ alert("Error"); }, </code></pre>
    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.
 

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