2017-08-28 108 views
0

請幫助,我想從2個URL加載2個JSON,這會加載調查問題。如果我只是加載1個JSON,輸出仍然正常,但是如果輸出2個JSON,輸出爲文本object,本調查是從surveyjs.io調查js,那裏是我的代碼。請幫幫我。加載2 json輸出文本對象

var baris1,baris2 = []; 
var url1='url_link'; 
var url2='url_link'; 

$.when($.getJSON('url_link'),  $.getJSON('url_link') 
).done(function(baris1,baris2){ 
    //baris = data 
    baris1 = JSON.stringify(s.baris1) 
baris2 = JSON.stringify(s.baris2); 
    //alert(baris1); 

Survey.Survey.cssType = "bootstrap"; 

var surveyJSON = {pages:[{elements:[ 
    {type:"matrix",columns:[ 
     {value:1,text:"Strongly Disagree"}, 
     {value:2,text:"Disagree"}, 
     {value:3,text:"Neutral"}, 
     {value:4,text:"Agree"}, 
    {value:5,text:"Strongly Agree"}], 
//name:"Pedagogik",rows:baris, 
name:"Pedagogik",rows:baris1, 
//title:"Silakan Jawab Dengan Sejujur-jujurnya" 
}, 
{type:"matrix",columns:[ 
    {value:1,text:"Strongly Disagree"}, 
    {value:2,text:"Disagree"}, 
    {value:3,text:"Neutral"}, 
    {value:4,text:"Agree"}, 
    {value:5,text:"Strongly Agree"}], 
//name:"Pengetahuan Umum",rows:baris, 
name:"Pengetahuan Umum",rows:baris2, 
//title:"Silakan Jawab Dengan objektif" 
}]}]} 

function sendDataToServer(survey) { 
//send Ajax request to your web server. 
alert("The results are:" + JSON.stringify(s.data));} 

var survey = new  Survey.Model(surveyJSON); 
$("#surveyContainer").Survey({ 
    model: survey, 
    onComplete: sendDataToServer 
}); 

}); 

回答

0

終於讓我找到了答案,只是聲明數組輸出的數量,

Row: baris1; 

更改爲

Row: baris1,[0]; 

只是它