I am returning a json as shown below
{\"name\": \"\", \"skills\": \"\", \"jobtitel\": \"Entwickler\", \"res_linkedin\": \"GwebSearch\"}
I a
It looks like data
not contains what you think it contains - check it.
let data={"name": "", "skills": "", "jobtitel": "Entwickler", "res_linkedin": "GwebSearch"};
console.log( data["jobtitel"] );
console.log( data.jobtitel );
you have parse that Json
string using JSON.parse()
..
}).done(function(data){
obj = JSON.parse(data);
alert(obj.jobtitel);
});
A simple approach instead of using JSON.parse
success: function(response){
var resdata = response;
alert(resdata['name']);
}
http://jsfiddle.net/v8aWF/
Worked out a fiddle. Do check it out
(function() {
var oJson = {
"name": "",
"skills": "",
"jobtitle": "Entwickler",
"res_linkedin": "GwebSearch"
}
alert(oJson.jobtitle);
})();
var data = {"name": "", "skills": "", "jobtitel": "Entwickler", "res_linkedin": "GwebSearch"}
var parsedData = JSON.parse(data);
alert(parsedData.name);
alert(parsedData.skills);
alert(parsedData.jobtitel);
alert(parsedData.res_linkedin);
//By using jquery json parser
var obj = $.parseJSON('{"name": "", "skills": "", "jobtitel": "Entwickler", "res_linkedin": "GwebSearch"}');
alert(obj['jobtitel']);
//By using javasript json parser
var t = JSON.parse('{"name": "", "skills": "", "jobtitel": "Entwickler", "res_linkedin": "GwebSearch"}');
alert(t['jobtitel'])
Check this jsfiddle
As of jQuery 3.0, $.parseJSON is deprecated. To parse JSON strings use the native JSON.parse method instead.
Source: http://api.jquery.com/jquery.parsejson/