1行JavaScript代码
$.post('/blah', { comment_id: 1, description: ... });
由于某种原因,该调用不是作为 JS 调用进行的,并且按照 documentation ,post
方法允许另外 2 个可选参数,success
和 dataType
。我想跳过 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/