jQuery$.post TypeError:e.type不是函数
jQuery $.post TypeError: e.type is not a function
我正在尝试为ZetaBoards论坛软件构建一个反馈脚本,我创建了一个$.post函数,当我试图通过单击提交按钮提交表单时,它只会在Firebug中返回"TypeError:e.type不是函数"。
这是我的代码:
<script type="text/javascript">
var forumID = '1701794';
if (location.href.indexOf('/profile/') !== -1) {
$('table.profile:last').after('<form id="feedback_form"><table class="profile" id="feedback"><thead><tr><th colspan="4">Feedback</th></tr></thead><tbody><tr><th colspan="4">Overall Rating: # (Positive: #, Neutral: #, Negative: #)</th></tr><tr><td colspan="4">Submit feedback: <input type="text" name="comment" size="100" /> <input type="radio" name="feed_rate" value="3">0 <input type="radio" name="feed_rate" value="1">1 <input type="radio" name="feed_rate" value="2">2 <button type="button">Submit</button></td></tr><tr><th>Rating</th><th>Comment</th><th>From</th><th>Date</th></tr></tbody></table></form>');
var profileID = window.location.href.split('profile/')[1].split('/')[0];
$.get(main_url + 'forum/' + forumID + '/', function (data) {
$('table.posts:not(#announcement_list) tr[class*="row"]', data).each(function () {
var userID = $(this).find('td.c_cat-title a').text().split('~')[0];
var rating = $(this).find('td.c_cat-title a').text().split('~')[1];
var comment = $(this).find('div.description').text();
var userHref = $(this).find('td.c_cat-starter a').attr('href');
var userText = $(this).find('td.c_cat-starter a').text();
var date = $(this).find('div.t_lastpostdate').text();
if (profileID === userID) $('#feedback tbody').append('<tr><td>' + rating + '</td><td>' + comment + '</td><td><a href="' + userHref + '">' + userText + '</a></td><td>' + date + '</td></tr>');
});
});
$('#feedback button').click(function () {
var userID = window.location.href.split('profile/')[1].split('/')[0];
var description = $('input[name="comment"]').val();
var rating = $('input[name="feed_rate"]:checked').val();
var title = userID + '~' + rating;
$.get(main_url + 'post/?type=1&mode=1&f=' + forumID, function (data) {
var ast = $('input[name="ast"]', data).val();
var xc = $('input[name="xc"]', data).val();
$.post(main_url + 'post/', $.extend({
mode: 1,
type: 1,
ast: ast,
f: forumID,
xc: xc,
sd: 1,
title: title,
description: description,
post: description + '~' + title
}));
});
});
}
</script>
以下是我使用它的位置:http://s1.zetaboards.com/Cory/profile/62973/
使用测试帐户登录:
用户名:测试
密码:Test1
您正在用值1覆盖函数$.type
中内置的jQuery。$.post调用中$.extend({})
的用途是什么?这就是导致错误的原因。
替换为:
$.post(main_url + 'post/', {
mode: 1,
type: 1,
ast: ast,
f: forumID,
xc: xc,
sd: 1,
title: title,
description: description,
post: description + '~' + title
});
在没有第二个参数的情况下调用$.extend()
将覆盖jQuery对象的默认属性。
相关文章:
- 创建一个类似链接的按钮,并通过Javascript函数打开一个新的弹出窗口
- 将函数的上下文应用于javascript变量
- 如何在JavaScript中将字符串转换为函数引用
- 用嵌套函数和默认函数定义函数
- 使用 jQuery 的 .on 函数如何获取事件的原始元素
- 无法导出函数expressjs/requestjs中的变量
- 函数参数中的数据与指定变量之间的任何性能差异
- JQuery合并了keyup和focusout两个函数
- 如何将输入(type=text)从html表单传递到javascript函数
- jQuery$.post TypeError:e.type不是函数
- lodash Type Error 没有函数 findKey()
- Sencha Touch Uncatch type错误:undefined 不是一个函数
- JavaScript 函数检索输入 [type=number] 并根据值过滤它们
- 在Node.js中重新创建pack()-type函数
- 在c#中使用selenium.type()方法会引发错误a. createeventobject不是函数
- javascript中的拆分函数输入type = "text"
- Uncaught Type错误鼠标滚轮不是函数
- 获取 s.Type.ToUpperCase() 不是使用 $ajax 调用 WCF 服务时的函数
- 谷歌编译器的注释,带有可选参数的@type函数
- React-router: type.toUpperCase 不是一个函数