我在控制台中收到此错误:
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不是函数
发布评论