$就删除请求,水豚,WebKit的不发送数据参数 [英] $.ajax delete request not sending data parameters in capybara-webkit
问题描述
我发现我的AJAX DELETE请求不发送数据参数到控制器,当我通过水豚,WebKit的执行。然而,数据参数也被发送(和测试通过),当我运行测试套件通过使用硒。我的code如下所示:
I'm finding that my ajax DELETE requests are not sending data parameters to the controller when I execute them through capybara-webkit. However, the data parameters do get sent (and the test passes) when I run the test suite by using selenium. My code looks like the following:
$(document).on 'click', 'a.delete_contact', ->
if confirm "Are you sure you want to delete this contact?"
id = $('a.delete_contact').data('id')
name = $('a.delete_contact').data('name')
$.ajax '/contacts',
type: 'DELETE'
dataType: 'html'
data: {'id' : id}
success: ->
$("li[data-cid='#{id}']").remove()
removeInitial(_.last(name.split(" "))[0])
show_notice("Contact successfully destroyed.", 'notice')
window.contactSelection.pop()
refreshSelectionView()
return false
任何想法,为什么这种失败在水豚,WebKit的?
Any ideas why this is failing in capybara-webkit?
推荐答案
显然QtWebKit的不支持的实体机构,DELETE请求。
Apparently QtWebKit does not support an entity body with DELETE requests.
的https://github.com/thoughtbot/capybara-webkit/issues/427#issuecomment-12200262
一个水豚,WebKit的开发者推荐使用这种解决方法:...... [发送]有一个参数标识请求为删除此机制是Rails的工作,跨浏览器的周围类似的问题POST请求
A capybara-webkit developer recommended this work-around: "[Send] a POST request with a parameter identifying the request as a DELETE. This mechanism is used by Rails to work around similar issues across browsers."
这篇关于$就删除请求,水豚,WebKit的不发送数据参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!