Possible Duplicate:
django file upload from json
Hi am using the following ajax upload from the template but i do not get a response from django view.What is wrong here..i do not see any alert
function ajax_upload(formid)
{
var form = $(formid);
form.ajaxSubmit({
dataType: 'json',
success: function (data) {
alert("Hereeeeeeee");
if(data.status == '1')
{
alert("Uploaded Successfull");
}
else
{
alert("Uploaded UnSuccessfull :(");
}
}
} ) ;
}
EDIT
Django:
def someview(request):
response_dict={'status':1}
logging.debug("seen") //This is seen in the logs
return HttpResponse(simplejson.dumps(response_dict), mimetype='application/javascript')
EDIT1
Please also for complete source code look at django file upload from json
From your code:
form.ajaxSubmit({
dataType: 'json',
success: function (data) {
alert("Hereeeeeeee");
Your callback executes on 'success', so we can narrow down the failure to the django view side. Assuming everything is syntactically correct, my best guess is that since you're returning json data, your response mimetype should be:
mimetype='application/json'.
If that doesn't work, I would suggest using Firebug on Firefox or Developer Tools on Chrome to look at the server response. You should be able to see a django stacktrace there.