jquery - Parse error 200 Json ajax webapp2 -



jquery - Parse error 200 Json ajax webapp2 -

i have ajax phone call jquery

function admin_ajax_pop_rows(){ $(document).ready(function(){ variable1= 'none'; $.ajax({ type: "post", url: "/someurl", datatype: "json", data: json.stringify({"variable1": variable1}) }) .success(function(data){ alert('success response: ' + info + ' number of rows : '); }) .done(function(data){ alert ('rows : ' + data.return_rows); maketablejquery(data); }) .fail(function(error){ alert('error status : ' + error.status + ' text: ' + error.statustext + ' response text : ' + error.responsetext); }); }); }

and in python server code have

def post(self): user_key = ndb.key(self.user_model,'value') user_key_parent = user_key.parent() user_query = self.user_model.query(ancestor = user_key_parent).order(ndb.genericproperty(sort_field)) query_data = user_query.fetch(i, projection=[ndb.genericproperty('name'),ndb.genericproperty('last_name'),ndb.genericproperty('email_address')]) table_prop_data = { 'return_rows': 9 , 'return_cols' : 8} return_table_prop_data = [] return_table_prop_data = json.dumps(table_prop_data) return_data = [] return_data = json.dumps([dict(p.to_dict(), **dict(id=p.key.id())) p in query_data],default = date_handler) self.response.headers['content-type']=("application/json;charset=utf-8") self.response.out.write(return_data) self.response.headers['content-type']=("application/json;charset=utf-8") self.response.out.write(return_table_prop_data)

i error of "200" status of "parse error"

jsonlint shows json error

parse error on line 74: ...662981951488 }]{ "return_cols": ---------------------^ expecting 'eof', '}', ',', ']'

i using webapp2 on gae

per felix' suggestion tried create dictionary using next -

return_data = json.dumps({'table_props': dict(table_prop_data), 'query_data' : [dict(p.to_dict(), **dict(id=p.key.id())) p in query_data],default = date_handler})

i getting syntax error. please help me prepare this. here date_handler function. need take care of datetime fields in query.

def date_handler(obj): homecoming obj.isoformat() if hasattr(obj, 'isoformat') else obj

you seem seek homecoming 2 individual json blobs in single response. can't work, can see jsonlint error. whole response must 1 single json blob.

jquery ajax json webapp2

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -