I got a problem with requesting a file via ajax post request.
I wonder how do I map my file on an ajax call to match the servers pathing? I don't get why it is not working (was using XAMPP before switching to a gulp webserver). Here is my project structure:
./
|_ site/
| |_ index.html
| |_ php/Gallery.php
| |_ assets/
| |_ js/
| |_ Ajax.js
| |_ test.html
|
|_ dist/
|
|_ gulpfile.js
|_ package.json
|_ ...
The Ajax.js file does an Post request to get php/gallery.php however I get a 404. I tried "php/Gallery.php" and "../../php/Gallery.php" as a path (and lots of others but try and error did not get me any further)
The Ajax call:
$.ajax({
url: "php/Gallery.php",
type: 'post',
data: { width: $(window).width(), galleryWidth: $('.popup-gallery').innerWidth(),},
cache: false,
beforeSend: function(){
$( ".ajax-loading" ).css('display', 'block');
},
success: function(json) {
... do something
},
error: function(err) {
console.log("Ajax Error: "+ err);
}
}); // end ajax call
I tried to access the test.html file inside of my /js folder with the path: "assets/js/test.html" and I get a 404 there too. If I type the URL "http://localhost:3000/assets/js/test.html" the test.html file gets displayed fine with its "Hello world" so I get really confused.
See picture: http://oi59.tinypic.com/n71op0.jpg (external link cause you need 10 reputation to post images, sadly)
If someone could explain what I am doing wrong here or where's my mistake I would be really grateful!
Thank you