未捕获的TypeError:$ .post不是函数

编程入门 行业动态 更新时间:2024-10-28 07:31:27
本文介绍了未捕获的TypeError:$ .post不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在控制台中收到此错误:

I am getting this error in Console:

未捕获TypeError:$ .post不是函数

Uncaught TypeError: $.post is not a function

这段代码:

<script type="text/javascript"> $('#cl_submit').click(function() { //#cl_submit is a button $('#cl_stage1msg').html('Processing...'); $.post("process/cookie.php", $("#cl").serialize(), function(response) { //#cl is a form $('#cl_stage1msg').html(response); }); return false; }); </script> <!-- popup included -->

我在这里找不到任何错误。为什么这不起作用,有什么线索?

I just couldn't find anything wrong in this. Why is this not working, any clues?

然而, $('#cl_stage1msg')。html('Processing ...'); 工作正常。

似乎只有帖子功能无法识别。

Seems like only the post function is not getting recognised.

我正在使用 code.jquery/jquery-3.1.0.slim.min.js

推荐答案

您正在使用jQuery的瘦身版,没有AJAX (在您的情况下 $ .post()功能)。

You are using the slim version of jQuery, which doesn't have AJAX (in your case the $.post() function).

使用非瘦身版,可在此处找到 jquery/download/ ,例如:

Use the non-slim build, available here jquery/download/, such as:

https: //code.jquery/jquery-3.3.1.min.js

来自 jQuery 3.0发布帖子:

Slim build

Slim build

[...]有时你 don'需要ajax,或者您更喜欢使用众多专注于ajax请求的独立库中的一个。[...]以及re包含 ajax和效果模块的jQuery的gular版本,我们发布了一个苗条版本[...],它排除了ajax,特效和目前已弃用的代码。

[...] Sometimes you don’t need ajax, or you prefer to use one of the many standalone libraries that focus on ajax requests.[...] Along with the regular version of jQuery that includes the ajax and effects modules, we’re releasing a "slim" version [...], it excludes ajax, effects, and currently deprecated code.

更多推荐

未捕获的TypeError:$ .post不是函数

本文发布于:2023-11-23 03:44:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619967.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   TypeError   post

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!