2014-07-11 37 views
1

語境:Highcharts是,jQuery 1.9.1JQuery的無法解析這個HTML

我得到一個Syntax error, unrecognized expression:了以下HTML和JavaScript $.get從我們自己的網站-ed的。

jQuery抱怨什麼?如果我們在瀏覽器中執行Demo2_SP_plunkerPartial.prx,它可以正常工作。 (.prx是一個內部SSL的擴展。)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 

<html> 

<body> 
<div> 
    <div id="content"> 
    content from the partial 
    </div> 
    <div>Some other content</div> 
    <script> 
     alert('this is the alert from the partial') 
    </script> 

<SCRIPT type="text/javascript"> 
$(function() { 
    $('#container').highcharts({ 
    chart : { 
     zoomType : 'xy' 
    }, 
    title : { 
     text : ' ' 
    }, 
    legend : { 
     align : 'center', 
     verticalAlign : 'bottom' 
    }, 
    xAxis : [{ 
     categories : ['0-100', '101-200', '201-300', '301-400', '401-500', '501-600', '601-700', '701-801', '901-1000', '1001-2000', '2001-5000', '5000+'] 
     } 
    ], 
    yAxis : [{ // Primary yAxis 
     labels : { 
      style : { 
      color : '#89A54E' 
      } 
     }, 
     title : { 
      text : 'Customers', 
      style : { 
      color : '#89A54E' 
      } 
     } 
     }, { // Secondary yAxis 
     title : { 
      text : 'Value ($)', 
      style : { 
      color : '#4572A7' 
      } 
     }, 
     labels : { 
      style : { 
      color : '#4572A7' 
      } 
     }, 
     opposite : true 
     } 
    ], 
    tooltip : { 
     shared : true 
    }, 
    series : [{ 
     name : 'Value ($)', 
     color : '#4572A7', 
     type : 'column', 
     yAxis : 1, 
     data : [52250, 195985, 512810, 318107.5, 1287202.5, 362520, 80037.5, 290510, 85975, 1403007.5, 1248727.5, 1025857.5, 172330] 

     }, { 
     name : 'Customers', 
     color : '#89A54E', 
     type : 'column', 
     data : [550, 1032, 1918, 842, 2712, 639, 121, 389, 101, 1477, 841, 354, 24] 
     } 
    ] 
    }); 
}); 
</SCRIPT> 
</div> 
</body> 

</html> 

這是我使用來獲取和解析頁面的JS代碼:

$(function(){ 
    $.get('Demo2_SP_plunkerPartial.prx', function(result){ 
     try { 
      $result = $(result); 
     } catch (e) { 
      console.log(e); 
     } 
     $result.find('#content').appendTo('#new_content'); 
     $result.find('script').appendTo('#new_content'); 
    }, 'html'); 
}); 
+0

應該'$ result = $(result);'是'var $ result = $(result);'? – PitaJ

+0

它看起來像jQuery解析器不喜歡'result'的值...你可以嘗試'var $ result = $($。trim(result));' –

+0

[Issue](http://jsfiddle.net/arunpjohny/yz6T4/2 /) - [修復](http://jsfiddle.net/arunpjohny/yz6T4/1/) –

回答

1

我碰到一個小測試你的代碼,它似乎對我有用,你確定服務器在給你「GET」響應之前沒有運行某種解析?

Here is my test,圖表似乎工作。