Note that there are some explanatory texts on larger screens.

plurals
  1. POdjango file upload from json
    primarykey
    data
    text
    <p>Hi i have given the complete code for my file upload .But in my views i am just trying to return a response and get the alert on the UI.But none of the return statements are working.How to rectify this..</p> <p><code>EDIT</code> : i see the logging statements on the server side</p> <pre><code> &lt;h1&gt;Add Content&lt;/h1&gt; &lt;form method="post" enctype="multipart/form-data" id="contentform" action="/content/savecontent/" &gt;{% csrf_token %} &lt;b&gt; &lt;table&gt; &lt;tr&gt;&lt;td&gt;&lt;font&gt;*&lt;/font&gt;Content Name&lt;/td&gt;&lt;td&gt; &lt;input type="text" id="cname" name="cname" maxlength="30"/&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;font&gt;*&lt;/font&gt;Description&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="cdescription" name="cdescription" maxlength="30"/&gt; &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;font&gt;*&lt;/font&gt;Type&lt;/td&gt;&lt;td&gt; &lt;select id="type" name="type"&gt; &lt;option value="1" selected&gt;Local&lt;/option&gt; &lt;option value="2"&gt;Internet&lt;/option&gt; &lt;/select&gt; &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;font&gt;*&lt;/font&gt;Access&lt;/td&gt;&lt;td&gt; &lt;select id="access" name="access"&gt; &lt;option value="1" selected&gt;Public&lt;/option&gt; &lt;option value="2"&gt;Private&lt;/option&gt; &lt;/select&gt; &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;font&gt;*&lt;/font&gt;Content&lt;/td&gt;&lt;td id="carea"&gt; &lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="button" value="Upload" id="addbtn" onclick="ajax_upload('#contentform');"/&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;/b&gt; &lt;/form&gt; &lt;script&gt; $(document).ready(function() { $('font').css({'color':'red'}) $("#carea").html('').append('{{form.file_upload}}'); }); function ajax_upload(formid) { var form = $(formid); form.ajaxSubmit({ dataType: 'json', success: function (data) { alert("hereeeeeee"); } } ) ; } &lt;/script&gt; </code></pre> <p>views.py</p> <pre><code>def savecontent(request): response_dict={'status':1} logging.debug(request) logging.debug("========================================") return render_to_response('content/confirmation.html', context_instance=RequestContext(request, {'response_dict':response_dict})) #return HttpResponse(simplejson.dumps(response_dict), mimetype='application/javascript') #return HttpResponse(simplejson.dumps(response_dict), mimetype='text/html') #return HttpResponse(simplejson.dumps(response_dict), mimetype='application/json') </code></pre>
    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