0

我有一个奇怪的错误,我将这些文件包含在我的部分中

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/barScriptOOP.js"></script>

在 barScriptOOP.js 我有这个

function position_bar(){
    //global variable
    this.sizes      = Array();
}
//class methods => getData (from xml file), draw(draws the bar )
position_bar.prototype ={
    getData: function(is_load){

        var xmlData = Array();
        $.ajax({
            type: "GET",
            url: "Bar.xml",
            dataType: "xml",
            context: this,
            success: function(xml) {

                //extracting new data - some code here
                                xmldata = "blabla";
                this.draw(is_load, xmlData);
            }
        })//end ajax

    }, 
//other functions 

当我使用此脚本时,我收到“$.ajax 不是函数”错误。1. 我试着编辑出来this.draw(is_load, xmlData);,它没有出错。我的程序 rpeatly 调用 getData 函数。

注意:我还收到'$.browser is undefined'另一个函数中的错误(这是我收到的第一个错误)。

意思==> 去另一个函数无法jquery。

知道这里发生了什么吗?

4

1 回答 1

0

不要使用 $ 作为您的 jquery 引用,而是尝试将此行放在脚本的开头

var $j = jQuery.noConflict();
$j(function() {
  alert('doc ready');
});

(另外,奇怪的是您的脚本标签没有设置类型属性,尽管我怀疑这是问题所在)

于 2012-06-01T07:43:40.693 回答