我一直在尝试修复过去2小时内的这个问题,但是我一直无法修复它。所以,我有当前filesetup:(jquery)尝试使用ajax查找php文件时出现404错误
classes
-html
--index.html
--front_gallery.php
-javascript
--gallary.js
我的心一直在这里以下教程:http://webdevelopingcat.com/jquery-php-beginner-tutorial-ajax/,我也跟着它几乎一模一样。我目前只是从电脑上运行网站。
所以,如果我从Adobe Brackets实时预览中运行它,我会得到404错误,说没有找到该文件。但是,如果我直接运行它,我得到这个错误:
XMLHttpRequest cannot load file:///C:/Users/myaka_000/Dropbox/Public/dylan_ferris_website/classes/html/front_gallery.php. Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https, chrome-extension-resource.
这里是gallery.js代码:
$(document).ready(function() {
$(function() {
$("#contact").submit(function(e) {
e.preventDefault();
var formData = $(this).serialize();
window.console.log(formData)
$.ajax({
type: "POST",
url: "front_gallery.php",
data: formData,
success: function(resp){
window.console.log(resp);
}
});
});
});
});
front_gallery.php:
<?
print_r($_POST);
的http:// STAC koverflow.com/questions/20041656/xmlhttprequest-cannot-load-file-cross-origin-requests-are-only-supported-for-ht – MH2K9 2014-11-22 04:31:30