Module 如何使用REQUIRE.js加载js.aspx文件

Module 如何使用REQUIRE.js加载js.aspx文件,module,requirejs,Module,Requirejs,我正在使用Microsoft dynamic CRM,它有一个名为ClientGlobalContext.js.aspx的文件来提供Xrm对象,还有很多自定义脚本。其中一些文件正在使用ClientGlobalContext.js.aspx中的Xrm对象。 现在我想使用require.js管理我的所有Javascript文件,但是如何使用require.js加载ClientGlobalContext.js.aspx呢 这就是我正在尝试的 requirejs.config({ //By de

我正在使用Microsoft dynamic CRM,它有一个名为
ClientGlobalContext.js.aspx的文件来提供Xrm对象,还有很多自定义脚本。其中一些文件正在使用
ClientGlobalContext.js.aspx中的Xrm对象。

现在我想使用require.js管理我的所有Javascript文件,但是如何使用require.js加载ClientGlobalContext.js.aspx呢

这就是我正在尝试的

requirejs.config({
    //By default load any module IDs from js
    baseUrl: '',
     //here we set our js folder
    //config is relative to the baseUrl, and
    //never includes a ".js" extension since
    //the paths config could be for a directory..
     paths: {
                'jquery':'//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min',//set jQuery path you can also include your folder js
                'jqueryui':'//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min',// set jQuery ui path you can also include your folder js
                'SDK.JQuery':"sample_/Scripts/SDK.JQuery",
                'json2':"sample_/Scripts/json2",
                'new_connexx':"new_connexx",
                // 'new_common':"new_common",
                'new_moment':"new_moment.min",
                'new_controls':"new_controls",
                'ClientGlobalContext': 'ClientGlobalContext.js.aspx'
          },
    shim: {

    'new_controls': {
        deps: ['new_moment','new_connexx'],// here we are defining that it depends on jQuery

    },
    'new_connexx':{
        deps:['jqueryui']
    },
    'jqueryui':{
        deps:['jquery','json2','SDK.JQuery']
    },
    'SDK.JQuery':{
        deps:['ClientGlobalContext']
    },
    'new_moment':{
        deps:['jqueryui']
    },
    'new_common':{
        deps:['jqueryui']
    },
    'new_letter_wizard':{
        deps:['jqueryui']
    }



 },
});

如果我遗漏了什么,请提出建议。

我找到了一个简单的解决方法。正如您从评论中了解到的那样,您没有包含.js扩展名,因为require会尝试为您处理该扩展名。这对于CRM 2011来说并不是一个很好的解决方案,因为您试图使用扩展名为.aspx的文件。ClientGlobalContext.js.aspx很有用,但它也是动态生成的,因此没有可用的静态版本。但是,解决方案是添加查询字符串。当require看到这一点时,它不会尝试为您添加.js扩展,所以只需更改这一行:

'ClientGlobalContext': 'ClientGlobalContext.js.aspx'
为此:

'ClientGlobalContext': 'ClientGlobalContext.js.aspx?foo=bar'

您并不真正关心查询字符串的值是什么,它只是为了防止requirejs过于聪明而损害自身利益

它怎么会失败呢?你收到错误信息了吗?有一些你期待的效果没有发生?请在你的问题中具体说明。