2016-04-25 14 views
0
  this.on('success', function(file, responseText) { 
       var theID = JSON.stringify(responseText); 
       alert(theID); 

       window.location.href = ('want to put something here');  

      }); 

アラートが私に与えている:JSON文字列の一部を取得するには?

{「メッセージ」:「成功」、「ファイルID」:399}

と私は、この場合にされるであろう、ファイルIDの値を取得したいと思います399. ありがとうございます。 responseTextはすでにJSON

+1

'responseText.fileID' –

+0

ifが' text'より 'JSON'オブジェクトの場合 – Rayon

答えて

3

単に

window.location.href = responseText.fileID; 

はその後、実行します:

responseText.fileID 

それは文字列の形式である場合には、最初に解析する:

var json = JSON.parse(responseText); 
alert(json.fileID); 
1
this.on('success', function(file, responseText) { 
      var theID = JSON.stringify(responseText); 
      alert(theID); 

      if(responseText.fileID == 399) { 
       // Do something 
      } 
      window.location.href = ('want to put something here');  

     }); 
1

あるので、responseTextがJSON形式で既にある場合

関連する問題