先上json的資料格式,底部有完整的php
{ "id":0, "success": true, "user":{ "ready":"0", "name":"", //這裡聲明了name,沒有聲明tel "sex":"", "addr":[{"prov":"1省","city":["a","b","c"]}, {"prov":"2省","city":["aa","bb","cc"]}, {"prov":"3省","city":["aaa","bbb","ccc"]}], "birth":"1992-06-15", "wx":"" }}
問用set方法建立tel的值?
user=this.model.get('user');user.tel=123;this.model.set('user',user)
上面這個方法在實際用法無效 tel的值沒有加進來
這裡卻又值
如果檔案中存在一個屬性,他是可以傳值的;
user=this.model.get('user');user.name=123;//tel換成namethis.model.set('user',user)
訪問的資料檔案如下:
true)); parse_str(file_get_contents('php://input'),$put_vars); $put_vars=json_encode($put_vars); die($put_vars); die; }else{echo '{ "id":0, "success": true, "user":{ "ready":"0", "name":"", "sex":"", "addr":[{"prov":"1省","city":["a","b","c"]}, {"prov":"2省","city":["aa","bb","cc"]}, {"prov":"3省","city":["aaa","bbb","ccc"]}], "birth":"1992-06-15", "wx":"" }}';}
回複內容:
先上json的資料格式,底部有完整的php
{ "id":0, "success": true, "user":{ "ready":"0", "name":"", //這裡聲明了name,沒有聲明tel "sex":"", "addr":[{"prov":"1省","city":["a","b","c"]}, {"prov":"2省","city":["aa","bb","cc"]}, {"prov":"3省","city":["aaa","bbb","ccc"]}], "birth":"1992-06-15", "wx":"" }}
問用set方法建立tel的值?
user=this.model.get('user');user.tel=123;this.model.set('user',user)
上面這個方法在實際用法無效 tel的值沒有加進來
這裡卻又值
如果檔案中存在一個屬性,他是可以傳值的;
user=this.model.get('user');user.name=123;//tel換成namethis.model.set('user',user)
訪問的資料檔案如下:
true)); parse_str(file_get_contents('php://input'),$put_vars); $put_vars=json_encode($put_vars); die($put_vars); die; }else{echo '{ "id":0, "success": true, "user":{ "ready":"0", "name":"", "sex":"", "addr":[{"prov":"1省","city":["a","b","c"]}, {"prov":"2省","city":["aa","bb","cc"]}, {"prov":"3省","city":["aaa","bbb","ccc"]}], "birth":"1992-06-15", "wx":"" }}';}
主要是由於model模型中不存在tel的值;所以無法被儲存;所以要在模型的預設屬性中先添加tel(空值也好,反正要聲明)
你倒底想問什嗎??先把錯別字改掉,把話講通順了。
你前端是修改了值然後傳到後台嗎?把前端的相關代碼貼出來吧
既然POST到php的資料是有tel的,說麼Model的資料已經修改了,去檢查你php的代碼,這和Backbone無關