JQuery的AJAX抛出404为现有网址 [英] JQuery AJAX throws 404 for an existing url
问题描述
我使用jQuery AJAX调用codeIgniter功能:
I'm using Jquery ajax to call a CodeIgniter function:
$.ajax({
type: "POST",
dataType:'json',
beforeSend: function() {
$("#opc").addClass("opacity");
$("#searching").show();
},
url: "<?php echo base_url(); ?>search/get_results",
data: {
'ns_pos':ns_pos,
'NSPlaceDomainID':activity,
'DistrictID':area,
'NSAssociationID':referer,
'Title':text,
'SettlementID':settlement,
'NoOpinion':$("input[name=NoOpinion]").is(":checked"),
'SpecialCharacteristics':ns_attr
}
等等...
etc...
在Chrome的控制台我得到的消息:
In the Chrome console I get the message:
POST http://mattat.org.il/ci/index.php/search/get_results 404 (Not Found)
响应preVIEW是:
the response preview is:
Not Found
The requested URL /ci/index.php/search/get_results was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
不过,此功能的确实存在,因为是显而易见的,当我简单地粘贴到URL行的链接。
However, this function does exist, as is evident when I simply paste the link in the URL line.
我很困惑......
I'm confused...
编辑:继@保罗的建设性意见我已经改为GET,事实上的要求,该页面被发现。哪些原因会导致这样一个不起眼的行为?
edit: Following @paul's constructive comment I have changed the request to GET and, indeed, the page was found. What can cause such an obscure behaviour?
一个步骤:当我清空数据对象(比如:数据:{}),该函数的是发现即使使用POST请求
One more step: When I empty the data object (like so: data: {}), the function is found even with POST request
推荐答案
由于保罗已经指出的,这可能是一个错误,由于GET / POST限制。检查您的服务器code,如果你支持这个端点POST请求。
As Paul already pointed, it is likely an error due to GET/POST limitation. Check your server code if you support POST requests on this endpoint.
这篇关于JQuery的AJAX抛出404为现有网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!