AJAX URL Path Issue

You need to be careful becasue if in your pathURL argument you have a relative path (something like ../../foo/bar) it will break when we use that prototype/ ajax call within a different file because the ajax call uses the path from the CURRENT PAGE you are on. So, it seems if you want to make the same ajax call on two different pages you would have to use an absolute path to the API endpoint otherwise it will be broken. You can make an absolute path my using /main/foo/bar.php.

from: https://stackoverflow.com/questions/24627075/jquery-ajax-url-path-issue

// current url: http://sample.com/users
// ajax code load from users page

$.ajax({
   url: '/yourFile.php',
   ...
});

// ajax url will be: http://sample.com/yourFile.php
// current url: http://sample.com/users
// ajax code load from users page

$.ajax({
    url: 'yourFile.php',
    ...
});

//...ajax url will be http://simple.com/users/yourFile.php