【问题标题】:Why am I getting $ is not defined error? [closed]为什么我收到 $ 未定义错误? [关闭]
【发布时间】:2013-11-05 11:27:31
【问题描述】:

我需要通过 ajax 调用一个 php 文件。我尝试了以下操作:

<html>
<script type="text/javascript">

setInterval(function(){
test();
},3000);

function test(){     
$.ajax({
    type: "POST",
    url: "GetMachineDetail.php",
    data: "{}",
    success: function(response){
         alert("suceccess");}
    });
}

这是简单的 javascript jquery 调用...但我有一个 ajax not found 错误。

问题:我该如何解决这个问题?

【问题讨论】:

标签: javascript php jquery ajax call


【解决方案1】:

$ 是由 jQuery 库提供的(名称不佳)函数。在您尝试使用它之前,您需要将该库包含在您的页面中。

您可以从jQuery website 获得它(您还可以在其中找到有关如何使用第三方托管版本的说明)。

【讨论】:

    【解决方案2】:

    需要在 HTML 中包含 jquery 库。

    仅仅因为使用没有库的 jquery 就会出错。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-28
      • 2012-01-30
      • 1970-01-01
      • 2013-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多