[英]AJAX Response Cannot Access Value Returned
我生成了一個 AJAX 來幫助我創建帳戶,我讓它返回正確的值,但現在我無法訪問這些值。 當 ajax 返回並且我console.log(this.reponse)
這是輸出的內容時:
{"errors":{"username":"Username is required.","email":"Email is required.","pass":"Password is
required.","con":"Confirmation Password is required."},"status":"error"}
當我嘗試執行this.response.errors
時,我收到一條未定義的消息。 我也嘗試過this.response["errors"]
並且得到了同樣的結果。 如何訪問用戶名、email、pass 和 con 等值。 任何幫助,將不勝感激。
使用JSON.parse()
對 json 響應 object
嘗試
var obj = JSON.parse(this.response)
console.log(obj.errors.username)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.