Reputation: 355
Rephrasing this question.
loadAjaxVals(script, json_action, id);
. This function is located in an external JS library. The script and json_action values aren't relevant to this question. The ID is the ID from the URL query stringHowever I want a second script located on editUser.php to parse the JSON and extract 1 piece of data from it.
I dont know how to access the JSON or parse the JSON.
Upvotes: 0
Views: 105
Reputation: 227240
The JSON is only available in the loadAjaxVals
function. I suggest you edit the loadAjaxVals
to accept a callback function.
Something like this:
function loadAjaxVals(script, json_action, id, callback){
// get JSON
// code
// parse JSON
// more code
if($.isFunction(callback)){
callback(data); // pass callback the parsed JSON data
}
}
Then call it like:
loadAjaxVals(script, json_action, id, function(data){
// use data
console.log(data);
});
Upvotes: 1
Reputation: 11130
Well you can use the 'in' operator to check if an object has an attribute ...
alert('enable_class' in obj)
should be true if indeed that object hast enbable_class either wise false
As for your second question, it may be possible that are you are using a cache version of the object, this is quite common, trust me, what I would recommend is clearing your cache and trying again, I also recommend Google Chrome javascript debugger which is built in and comes along with a very nice console and host of other niceties ... :)
If indeed the problem is the cache their are a couple ways around it ... I'll elaborate once you've confirmed it.
Upvotes: 0