drtzb06222
2013-03-03 01:08
浏览 97

函数适用于jquery 1.4.2但不适用于jquery 1.9.1

I have this script for submitting some data to my database. It works great on 1.4.2 but the template I am using requires 1.9.1 so I updated my site. The problem I am having is that I am now getting an error when I try to call the same function.

Here is my js code:

function drilldown(row_id){  
var dealID = document.getElementById('dealID'+ row_id).value;
var specialnotes = document.getElementById('specialnotes'+ row_id).value;
var ready = document.getElementById('ready'+ row_id).value;
var initials = document.getElementById('initials'+ row_id).value;
var forcust = document.getElementById('forcust'+ row_id).value;
var notes = document.getElementById('notes'+ row_id).value;

$.ajax({
    url: "savedrilldown.php",  
    type: "GET",
      //pass data like this 
    data: {dealID:dealID,specialnotes:specialnotes,ready:ready,initials:initials,forcust:forcust,notes:notes},    
    cache: false,
    success: function(data) {  
    if (data=="1")
    alert("Record updated!" );  
    } 

});  
}

And here is the error that firebug is showing me:

TypeError: $ is undefined [Break On This Error]     
$.ajax({

And here is what I am loading:

<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery-migrate-1.1.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.9.2.min.js"></script>

Any advise would be appreciated. Thanks very much.

图片转代码服务由CSDN问答提供 功能建议

我有这个脚本用于向我的数据库提交一些数据。 它在1.4.2上运行良好,但我使用的模板需要1.9.1,所以我更新了我的网站。 我遇到的问题是,当我尝试调用相同的函数时,我现在遇到错误。

这是我的js代码:

   function drilldown(row_id){
var dealID = document.getElementById('dealID'+ row_id).value; 
var specialnotes = document.getElementById('specialnotes'+ row_id).value; 
var ready = document.getElementById  ('ready'+ row_id).value; 
var initials = document.getElementById('initials'+ row_id).value; 
var forcust = document.getElementById('forcust'+ row_id).value; 
var notes = document。  getElementById('notes'+ row_id).value; 
 
 $ .ajax({
 url:“savedrilldown.php”,
 type:“GET”,
 //传递这样的数据
数据:  {dealID:dealID,specialnotes:specialnotes,ready:ready,initials:initials,forcust:forcust,notes:notes},
 cache:false,
 success:function(data){
 if(data ==“1  “)
 alert(”记录更新!“); 
} 
 
});  
} 
   
 
 

这是firebug向我展示的错误:

  TypeError:$ is undefined  [打破此错误] 
 $ .ajax({
   
 
 

这是我正在加载的内容:

 <  code>&lt; script type =“text / javascript”src =“js / jquery-1.9.1.min.js”&gt;&lt; / script&gt; 
&lt; script type =“text / javascript”src =“js /  jquery-migrate-1.1.1.min.js“&gt;&lt; / script&gt; 
&lt; script type =”text / javascript“src =”js / jquery-ui-1.9.2.min.js“&gt;&lt;  ; / script&gt; 
   
 
 

任何建议都将不胜感激。非常感谢。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanjie6912 2013-03-03 01:12
    已采纳

    $ is basically jQuery call, if it is not defined, it does not load your jquery for some reason.

    Make sure that jquery is loaded correctly and that it is loaded before executing jquery ajax.

    Also I want to suggest to use json and data type json to transfer data since it has perfect form to be transmitted via json.

    打赏 评论

相关推荐 更多相似问题