我认为我的 html 文件看不到另一个脚本文件

I think my html file doesn't see another script file

本文关键字:文件 看不到 脚本 另一个 html 我的      更新时间:2023-09-26

我有这个问题.我有两个文件,一个(soap.html(,另一个是(soap.js(

在html文件中,我使用了一个edarah_Authenticate的函数,这个函数存在于soap.js中,但这是错误:

"未捕获的引用错误: 未定义edarah_Authenticate"

如何使html文件看到soap.js文件中

的功能

这是 HTML:

 <script type="text/javascript" src="soap.js"> </script>
 <input type="text" name="username" 
 id="username" value="username" click="this.value=''"     class="user-name"> 
<input type="password" id="password"
name="password" value="password" onclick="this.value=''" class="user-name">

  <div class="login">
   <input type="button" id="signin" class="sign-button" onclick="
    var username=document.getElementById('username').value;
    var password= document.getElementById('password').value;
       edarah_Authenticate  (username,password, function(jsonResponse) {
        var auth = JSON.parse(jsonResponse);
        for (i=0;i<auth.length;i++){
        if ((msg[i]['id'])!==null)
           { 
         Redirect();
           }
             else { alert('Username or Password is incorrect');}
         }                               });">
            </div>

这是soap.js文件:

    function edarah_Authenticate(username, password, theCallBack)
  {
   method = "Authenticate";

   parameters = "<username xsi:type='xsd:string'>" + username + "</username>
    <password xsi:type='xsd:string'>" + password + "</password>";

      edarah_getDataFromWebService(method, parameters, theCallBack);
   }

还有继续,但我认为这就足够了。

查看浏览器的错误控制台:

未捕获的语法错误:意外令牌非法

在 JavaScript 中,字符串文字中间不能有新行。这会破坏您的函数声明。

JSHint 和 JSLint 也会发现这一点(就像其他一些问题一样,例如您将全局变量用于看起来不应该是全局变量的东西(。

我想你的代码是真的.

只是你要检查两个文件夹是否在同一个目录中,我觉得这个函数是WEB服务你必须把它当成客户端来代理。