2017-02-23 24 views
0

以下是代碼。我已經研究過它,到目前爲止還沒有找到合適的解決方案。任何幫助將非常感激。謝謝。

<script type="text/javascript" src="{%static 'javascript/jquery-3.1.1.js'%}"></script> 
 
    <script type="text/javascript"> 
 

 
\t \t $(document).ready(function(){ 
 
\t \t \t $("#itemid").change(function(){ 
 
\t \t \t \t var itemid = $(this).val(); 
 
\t \t \t \t var func_url = '/get_itemdetails/' + itemid +'/'; 
 
\t \t \t \t $.ajax({ 
 
\t \t \t \t \t type:"GET", 
 
\t \t \t \t \t url: func_url, 
 
\t \t \t \t \t dataType:"json", 
 
\t \t \t \t \t success: function(data){ 
 
\t \t \t \t \t \t console.log(data); 
 
\t \t \t \t \t } 
 
\t \t \t \t }); 
 
\t \t \t }); 
 
\t \t }); 
 
\t \t 
 
\t </script>

+0

HTTP:/ /api.jquery.com/jquery.ajax/,嘗試'f ail'回調,看看有什麼錯誤。 '$'是全球性的,不應該有這個問題。檢查控制檯內的'$' –

+0

http://stackoverflow.com/questions/18271251/typeerror-ajax-is-not-a-function –

+1

並非所有版本的jquery都帶有$ .ajax函數。在您的版本中搜索,看看它是否有它。 –

回答

2

下面是最新的腳本標頭爲谷歌的託管CDN它允許$就功能:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
    <script type="text/javascript"> 
 

 
\t \t $(document).ready(function(){ 
 
\t \t \t $("#itemid").change(function(){ 
 
\t \t \t \t var itemid = $(this).val(); 
 
\t \t \t \t var func_url = '/get_itemdetails/' + itemid +'/'; 
 
\t \t \t \t $.ajax({ 
 
\t \t \t \t \t type:"GET", 
 
\t \t \t \t \t url: func_url, 
 
\t \t \t \t \t dataType:"json", 
 
\t \t \t \t \t success: function(data){ 
 
\t \t \t \t \t \t console.log(data); 
 
\t \t \t \t \t } 
 
\t \t \t \t }); 
 
\t \t \t }); 
 
\t \t }); 
 
\t \t 
 
\t </script>

+0

謝謝你現在的工作 – Bigboss

+0

@Bigboss沒問題,我很高興我們可以弄明白! –

相關問題