ajax - Dictionary in JavaScript -
currently tried reform json data dictionary store needed data in array key , value.
* edit put full code. *
this how do:
var mydata = []; var urlpath = "https://tipjira.pgdev.abcd.com/rest/api/2/search?jql=project=grifr14%2band%2bfixversion=15018"; var jiramapping = []; $.ajax({ url : "http://frparwself22.dhcp.par.abcd.com:8080/jiraproxy/jira?url=" + urlpath, datatype : 'json', type: 'get', success : function(data) { (var i=0; i<data.issues.length; i++) { var obj = {}; obj[data.issues[i].key] = data.issues[i].self; jiramapping.push(obj); alert(jiramapping.length); } }, error : function() { alert("error!") } }); alert(jiramapping.length);
my original data {issues:[{...,"self":"/rest/api/2/issue/175074","key":"grifr14-36",...}, {...,"self":"/rest/api/2/issue/175075","key":"grifr14-37",...}, ...]}. , want reform have array key , value key , self.
so data in jiramapping should [{k1:v1}, {k2,v2}, ...]
. when tired print length of jiramapping, length 0. tried put alert check key , value add array , values exist.
i don't know problem exactly. please help...
without knowing information you're passing in, it's hard what's going wrong. being said, first guess data
/mydata
isn't formatted way think. instance, if mydata.issues.length
0
, nothing in loop executed.
there's chance you're never running success
function. post more code?
Comments
Post a Comment