2014-04-23 25 views
0

Ajax響應和商店,我想存儲從http://www.youtube-mp3.org/a/itemInfo/?video_id=Vd85aPZ-QAE&ac=www&t=grp接收到的變量和訪問info.h數據..我想這的jQuery - 獲得可變

$.ajax({ 
      async: false, 
      type: "GET", 
      url: "http://www.youtube-mp3.org/a/itemInfo/?video_id=Vd85aPZ-QAE&ac=www&t=grp", 
      dataType: "json", 
      success : function(info) { 
         xml = info.h; 
       alert(xml); // WORKS 
        } 
     }); 

,但沒有成功..

infoRehashCallback=function(){4==h.readyState&&("$$$ERROR$$$"==h.responseText?pushItemError():500==h.status?(error_count+=1,4<error_count&&pushItemMaintenance()):(eval(h.responseText),checkInfo()))};infoRehash=function(){var a=new Date;h=createRequestObject();a="http://www.youtube-mp3.org/a/itemInfo/?video_id="+video_id+"&ac=www&t=grp&r="+a.getTime();h.onreadystatechange=infoRehashCallback;h.open("GET",a,!0);hs(h);h.send(null)}; 
startInfoRehash=function(a){video_id=a;infoRehash();interval=window.setInterval("infoRehash()",1E3*interval_diff)}; 

我從網站上的JavaScript的代碼

+0

爲什麼你wanto其存儲在變量? –

回答

0

做出這樣的函數:

$.ajax({ 
      async: false, 
      type: "GET", 
      url: "http://www.youtube-mp3.org/a/itemInfo/?video_id=Vd85aPZ-QAE&ac=www&t=grp", 
      dataType: "json", 
      success : function(info) { 
         ShowAlert(info.h); 

        } 
     }); 

function ShowAlert(a) 
{ 
    alert(a); 
// do whatever want to with the result 
} 
+0

仍然沒有警報產生 – kk3nny

+0

它是否成功功能? –

+0

JSON響應無效..但我需要一個解決方法..這是響應信息= {「標題」:「你好 - 萊昂內爾裏奇」,「圖像」:「http://i.ytimg.com/ vi/Vd85aPZ-QAE/default.jpg「,」length「:」4「,」status「:」serving「,」progress_speed「:」「,」progress「:」「,」ads「:」「,」pf 「:」「,」h「:」f54ed003ec1b3b95be03a68dbcc5cba6「,」px「:」「}; – kk3nny

0

我得到了以下回應這不是有效的JSON:

info = {"status" : "serving", "h" : "-"}; 

應該是:

{"status" : "serving", "h" : "-"} 
+0

是的,這就是問題..有沒有解決這個問題的方法? – kk3nny

+0

nop它拋出一個解析錯誤無法處理響應。 – Wilmer

+0

我們可以從花括號解析它並離開「信息=」嗎? – kk3nny