jQuery跳过可选参数
Javascript jQuery skipping optional params
1行JavaScript代码
$.post('/blah', { comment_id: 1, description: ... });
由于某些原因,该调用不是作为JS调用进行的,并且根据文档,post
方法允许另外2个可选参数,success
和dataType
。我想跳过success
并将dataType
设置为script
。我试过了,它给了我一个错误
$.post('/blah', { comment_id: 1, description: ... }, ,"script");
通过null
或undefined
:
$.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。如果你想跳过一个参数,你必须传递一个null
值:
$.post('/blah', { comment_id: 1, description: 'Blah' }, null, "script");
默认参数可以为null
相关文章:
- 我的jQuery插件参数没有正确启动,遇到了问题
- jquery设置为使用参数运行
- 如何向这个javascript/jquery函数添加参数
- 如何使用JQuery在HTML中创建包含字符串参数的引号的onclickjavascript链接
- 为什么jQuery文件的函数中有两个参数,但只接收一个参数
- HTML 按钮点击函数无法使用 jQuery 变量作为参数
- 如何在扩展jQuery方法时传递参数
- 将额外的参数传递给jquery.延迟回调
- 使用jquery变量作为.net MVC中ActionLink的参数
- 如何使用jQuery插件参数变量
- 如何使用pass参数从jQuery.getJSON获取回调
- jQuery 无法使用 AJAX 调用访问函数内部的函数参数
- 如何用javascript替换Jquery字符串上的新参数
- 将字符串作为参数传递给函数onclick event jquery
- 带有键代码参数Jquery的模拟按键功能
- 如何使用jQuery上下文参数
- 如何传递参数 jQuery 并返回函数值
- 如何检测是参数jQuery对象
- 单击网址时抓取网址参数.Jquery,Javascript
- 如何在JavaScript中从数组中选择多个参数(jQuery.path)