JQuery.jsonParse not working
JQuery.jsonParse not working
我的代码是:
var json = $.parseJSON(data);
CKEDITOR.instances.post_editor.setData(json.content);
$("#postTitle").val(json.title);
$("#tagInput").val(json.tags);
但是它不设置值。当我运行console.log(json)
时,它记录:
{"标题":"Id、1","内容":"
测试。;/s> & lt;/u> & lt;/em> & lt;/强> & lt;/p> ' r ' n"、"标签":"标签,胡","日期":"2014年5月10日,20点","Id":"1"}
但是当我运行console.log(json.title)
时,它记录:undefined
// replace with your first line. Error is 'r'n breaking the data string
data = data.replace(/('r'n|'n|'r)/gm,"");
var json = $.parseJSON(data); // OR "JSON.parse(data);"
解析前必须将content
字段的value替换为'n
:
小提琴: http://jsfiddle.net/abdennour/rD3Jy/1
aa=aa.replaceAll("'n","###")
然后,解析后可以返回真实值(JSON.parse
):
aa.content.replaceAll("###","'n") ;
相关文章:
- $rootScope not working
- jQuery document.ready not working
- Javascript getElementsByTagName not working?
- JQuery.val( ) not working
- Tomcat websocket is not working
- Javascript JSON.parse not working
- NodeJS Multer is not working
- Regex not working
- Ember run.debounce not working
- AngularJs 1 not working
- document.getElementById.style.backgroundImage not working
- Rxjs5, distinct() is not working
- createOscillator noteOn not working
- Javascript - .getHours() not working
- Javascript setTimeout not working | onkeydown
- MongoDB $pull not working
- Express router.use not working
- JSONP not working
- window.opener not working in chrome & IE
- Backbone + RequireJS: Collection.each() is not working