无法访问localStorage.getItem(JSONObj)

时间:2016-03-31 09:17:55

标签: javascript ajax

如何访问localStorage.getItem(JSONObj)

的值
var result = JSON.parse(localStorage.getItem("resultData")); // ---In Ajax SuccessCallBack I have written var parseResult = JSON.stringify(result);localStorage.setItem("resultData",parseResult); --- 

alert("Result :"+result); // I get proper result here
var obj_res = result.getTest_Data; // PHP - $data['getTest_Data'] = $query->result(); ----// tried with result.getTest_Data[0] , result.["getTest_Data"]
//alert(obj_res);// Undefined
$("#txtTTDNo1").val(obj_res.QC_TTDNo1);  // Assigning Value to Text box

获取错误:

  

“无法读取未定义的属性”QC_TTDNo1。

1 个答案:

答案 0 :(得分:0)

解决。我不得不再次解析JSON,因为我是JSON.stringify()而localStorage.setItem("")...... var data1 = JSON.parse(result); var data = data1.getTest_Data;