My alert shows an "Undefined" with the following code:
var nonce = (function () {
$.ajax({
url: site_url + '/api/get_nonce/?controller=user&method=register&apikey=XXX&callback=?',
type: "GET",
dataType: 'json',
success: function(data){
nonce = data.nonce;
}
});
return nonce;
})();
alert(nonce);
The JSON is:
?({"status":"ok","controller":"user","method":"register","nonce":"XXX"})
What I'm doing wrong?