jquery - ERR EMPTY RESPOSNE 在 wordpress 中的 ajax 删除请求
问题描述
我正在尝试删除带有 REST api 端点的帖子。evry 在本地运行良好。但在直播(000webhost 服务器)上,它给出的错误没有响应文本。
http://mylivesite/wp-json/university/v1/nclike net::ERR_EMPTY_RESPONSE
这是js代码:
$.ajax({
beforeSend: (xhr) => {
xhr.setRequestHeader('X-WP-Nonce', universityData.nonce);
},
url: universityData.root_url + '/wp-json/university/v1/nclike',
type: 'DELETE',
//dataType: 'default: Intelligent Guess (Other values: xml, json, script, or html)',
data: {like: thisLikeBox.attr('data-likeid')},
})
.done((response) => {
thisLikeBox.attr('data-exists', 'no');
var likeCount = parseInt(thisLikeBox.find('.like-count').html(), 10);
likeCount--;
thisLikeBox.find('.like-count').html(likeCount);
thisLikeBox.attr('data-likeid', '');
console.log(response);
})
.fail((response) => {
console.log(response);
})
.always(function() {
console.log("complete");
});
}
错误指向主 jQuery.js 的这一行:
// Do send the request (this may raise an exception)
xhr.send( options.hasContent && options.data || null );
帮助!!:(
解决方案
推荐阅读
- jakarta-ee - 创建 JMSProducer 时如何提高性能?
- c - 为什么我的 C 代码在命令提示符下不断返回 0?
- android - 发现多个文件的操作系统独立路径为“META-INF/androidx.localbroadcastmanager_localbroadcastmanager.version”
- python - 为什么键入变量(或表达式)会将值打印到标准输出?
- mysql - 如何使用同一列内的计算
- django - Django:电子邮件未在内置 PasswordResetView 中发送
- c++ - 抛出异常:写访问冲突。p 是 0x1140000
- javascript - 如何将我的 document.write 字符串居中?
- php - 位置实时跟踪项目
- php - 如何在foreach中合并重复项