Javascript jQuery 跳过可选参数

标签 javascript jquery-ui

1行JavaScript代码

$.post('/blah', { comment_id: 1, description: ... });

由于某种原因,该调用不是作为 JS 调用进行的,并且按照 documentationpost 方法允许另外 2 个可选参数,successdataType。我想跳过 success 并将 dataType 设置为 script。我尝试了这个,但它给了我一个错误

$.post('/blah', { comment_id: 1, description: ... }, ,"script");

最佳答案

传递null未定义:

$.post('/blah', { comment_id: 1, description: ... }, null,"script");

// use void for undefined (because undefined can be reassigned)...
$.post('/blah', { comment_id: 1, description: ... }, void 0,"script");

关于Javascript jQuery 跳过可选参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7247949/

相关文章:

javascript - 使用 httpOnly cookie 进行设备注册

javascript - location.href 正在解码 URL

css - 如何在非事件选项卡上设置 ui-tabs-tab 悬停样式?

javascript - 在jquery中使用索引动画元素

jQuery UI 在 .hide ('blind' ).remove() 之后留下垃圾元素

jQueryUI 自动完成选项 - 样式问题

Jquery UI 组合框 - 从远程 url 加载

javascript - Firebase 在 React Native 数据获取中返回 "undefined"值

javascript - 使用 AJAX 将操作附加到最后附加的行

javascript - Uncaught ReferenceError : body is not defined