擅长:python、mysql、java
<p>您没有在任何地方重定向(self.route执行重定向)。另外,您不能在这里重定向,因为您正在执行ajax调用。我很确定电话和电子邮件的分配是不正确的,因为您正在将数组转换为字符串。我们明天在办公室讨论。同样,正如sza指出的,方法调用不传递self。</p>
<pre><code>@view_config(route_name="profile", request_method='POST')
def save_profile(self):
try:
json = self.request.json_body
#username = str(json['userName'])
first_name = str(json['firstName'])
last_name = str(json['lastName'])
phones = str(json['phones'])
emails = str(json['emails'])
self.profiles.update(firstName=first_name, lastName=last_name, emails=emails, phones=phones)
value = {'result:': 'success', 'message': 'Profile Saved!'}
except Exception, err:
print err
value = {'result:': 'error', 'message': 'There was an error processing the request'}
#returns a json response
return self.respond(value)
</code></pre>