weixin_33728268 2014-05-05 07:39 采纳率: 0%
浏览 30

用ajax加载脚本

I have a very strange problem. This function load a script on my IIS local web server.

function loadJs(scriptName) {
    var name = scriptName.toString();
    var myUrl = 'http://192.168.1.149/7.0.9.5/m/js/';
    myUrl += name;
    debugger;
    $.ajax({
        url: myUrl,
        dataType: "script",
        success: function () {  }
    });
}

When I check in debugger, I see that the url is correct.

enter image description here

But in fact, the ajax call doesn't use my url: enter image description here

While it should be this:

enter image description here

We can see that the request url is not the same. (The 403 code is normal because IIS block the access to the folder list).

On the other hand, if I directly put the url into the 'url' parameter, the load works.

function loadJs(scriptName) {
    var name = scriptName.toString();
    var myUrl = 'http://192.168.1.149/7.0.9.5/m/js/';
    myUrl += name;
    debugger;
    $.ajax({
        url: 'http://192.168.1.149/7.0.9.5/m/js/loadAccount.js',
        dataType: "script",
        success: function () {  }
    });
} 

enter image description here

If someone can propose an answer to this very strange problem. I'll be glad.

Thanks, in advance.

  • 写回答

2条回答 默认 最新

  • weixin_33725515 2014-05-05 07:44
    关注

    Try changing this line

    myUrl = myUrl + name;
    
    评论

报告相同问题?