I have searched just about everywhere on trying to do a call using ajax to a file that is up one level in the app folder. I am using a built from scratch mvc framework. I am using vscode as my editor and running php -S localhost in the terminal. This is the url being displayed
localhost:8080/somepage
here is the folder/file structure:
path for some.ajax.php: mvc\app\ajax\some.ajax.php
path for index.php: mvc\public\index.php
path for some.js: mvc\public\assets\js\some.js
here is the code
$(document).ready(function () {
var url = "../app/ajax/some.ajax.php";
gridSettings = {
url: url,
submitUrl: url,
selectUrl: url,
tableName: "sometable",
editable: false,
allowAdd: true,
allowDelete: true,
allowEdit: true,
refreshAfterUpdate: true,
};
$("#categories").editGrid(gridSettings);
});
so when I use ../app/ajax/some.ajax.php, I am getting an 404 error stating it cannot be found. POST http://localhost:8080/app/ajax/profile.ajax.php 404 (Not Found)
Then when using the full path to it http://localhost/mvc/app/ajax/some.ajax.php, I get the following error and the code will not process
errors from web dev console
Access to XMLHttpRequest at 'http://localhost/mvc/app/ajax/some.ajax.php' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. jquery-3.6.1.min.js:2
POST http://localhost/mvc/app/ajax/some.ajax.php net::ERR_FAILED 200
so any help would be appreciated.
source https://stackoverflow.com/questions/73839684/how-to-call-to-url-using-ajax-to-call-php-file-when-base-url-is-using-localhost
No comments:
Post a Comment