Im new on GM. Iv'e run into an problem on an array segment. Here is the code:
我是GM的新人。我遇到了阵列段的问题。这是代码:
var A1_rest= '';
var A1reset_go = false;
var auctiontyp = 0
var myJson = '{"d":[["","","y","ZAR","1","49517","6458, 8270, 8270, 8270, 7635",null,"1.40","6458","0:13:30","","12","","C","30",null],["y","-00:00","y","ZAR","2","49593","6458, 6458, 6458, 6458, 6458",null,"2.92","6458","0:13:37","","12","","L","12","Ve4mYdrvkkQMKxBH1\/1VMtDTCDQBRspg5jB8jjY08zg="],["","","y","ZAR","3","49058","7456, 9216, 6458, 5153, 7456",null,"194.40","7456","0:00:31","","1100","","T",null,null],["","","y","ZAR","4","49597","2935, 6554",null,"1.22","2935","0:01:16","","12","","T",null,null],["","","y","ZAR","5","49590","4440, 0518, 5343, 2625, 4848",null,"0.95","4440","0:15:58","","5","","L",null,null],["","","y","ZAR","6","49591","4848, 4440, 4440, 0518, 2625",null,"1.81","4848","0:16:05","","12","","L",null,null],["","","y","ZAR","7","49595","6458",null,"5.55","6458","0:04:13","","55","","T",null,null],["","","y","ZAR","8","49596","",null,"2.90","NONE","0:04:35","","29","","T",null,null],["","","y","ZAR","9","49496","6458, 2427, 2427, 7863, 5845",null,"2.56","6458","0:06:07","","10","","B",null,null],["","","y","ZAR","10","49524","6458, 2427, 7863, 7863, 5845",null,"1.67","6458","0:06:00","","5","","B",null,null],["","","y","ZAR","11","49539","6458, 2427, 7863, 7863, 0764",null,"2.02","6458","0:04:25","","10","","B",null,null]]}'
var jsonObj = $.parseJSON (myJson);
//--- The JSON should return a 2-D array, named "d".
var arrayOfAuctions = jsonObj.d;
//--- Loop over each row in the array.
$.each (
arrayOfAuctions,
function (rowIndex, singleAuctionData) {
//--- Print the 7th column.
console.log ('Row: ' + (parseInt (rowIndex) + 1) + ' Column: 7 Value: ' + singleAuctionData[6]);
//up to here its fine
auctiontyp=parseInt (singleAuctionData[4]);
if (auctiontyp== 1)
{
A1_rest=singleAuctionData[16];
alert(A1_rest);
alert(singleAuctionData[16]);
//2 alerts not the same...?
if (A1_rest != 'null')
{alert('doing incorrectly');
A1reset_go=true;
};
else
{alert('success1');
}
alert('check5.1');
alert(A1reset_go);
if (A1_rest == 'null') and (A1reset_go==true)
{alert('should also not run but does');
A1reset_go=false;
A1_start=singleAuctionData[8];
};
else
{alert('success2');
};
};
my current problem is on :"A1_rest" and "singleAuctionData[16]"
我当前的问题是:“A1_rest”和“singleAuctionData [16]”
I thought "singleAuctionData[16]" will be a text value of "null" , but it isnt, it is some other value, although, on an alert it gives an output of "null". I'm unsure how to test for it. In this scenario, on the array in the first segment, (which im testing) it should execute "success1" and "success2". On the second segment of the array, if i run the same test , it should only alert "doing incorrectly" and "success2". Can someone please help me? Thanks in advance. Ludwig
我认为“singleAuctionData [16]”将是“null”的文本值,但它不是,它是一些其他值,但是,在警报时它给出输出“null”。我不确定如何测试它。在这种情况下,在第一个段中的数组上(我测试)它应该执行“success1”和“success2”。在数组的第二段,如果我运行相同的测试,它应该只警告“做错”和“success2”。有人可以帮帮我吗?提前致谢。路德维希
1 个解决方案
#1
1
You are expecting a "text value of null", but I think the actual value is just null
, or nothing, rather than the text 'null'
.
您期望“文本值为null”,但我认为实际值只是null或什么都没有,而不是文本'null'。
#1
1
You are expecting a "text value of null", but I think the actual value is just null
, or nothing, rather than the text 'null'
.
您期望“文本值为null”,但我认为实际值只是null或什么都没有,而不是文本'null'。