2017-02-23 48 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没问题,我很高兴我们可以弄明白! –