jquery - Why does json.dumps() throw a 500 internal server error when using variables? -
i've tested out thoroughly , have no idea why it's doing this, wondering if explain...
json.dumps() throwing 500 internal server error when try use variable instead of string.
for example:
error = 'login failed: username or password incorrect.' test = json.dumps({'form': error})
will return 500 internal server error when attempting return through jquery.ajax
however,
test = json.dumps({'form': 'login failed: username or password incorrect.'})
will not throw 500 internal server error. i've tested out thoroughly single quotes, double quotes, different formatting, etc , points json.dumps()
for reason, occurring when calling view through jquery.ajax
if don't return json.dump() , return normal json object still throws 500 error, why i've concluded it's json.dumps() , not .ajax call **
here's snippet of code i'm using this: unknown reasons.. throw error while calling particular page through jquery.ajax()
yes.. though variable 'test' not being returned.
elif(password == 'testing_this'): error = 'login failed: username or password incorrect.' errors = true test = json.dumps({'form': error}) #print test date = datetime.date.today() if(errors == true): return httpresponse(json.dumps({'form': 'error message here'}), mimetype='application/json') else: return httpresponse(json.dumps({'result': true}), mimetype='application/json')
turning debug on in settings, , going through traceback may useful.
just of wall, may assume before check (if(errors == true):) may forgot initialize errors initial value throws nameerror... it's assumption.
upd: sorry ajax part slipped mind - +1 waitinforatrain's comment
Comments
Post a Comment