jQuery如何引用$ .post()目录

welcome how to file script.js refer to index.php?

in script.js:

$.post('../php/index.php', {data});

structure directory:

js/
  script.js
php/
  index.php
index.html

return me in console:

404 (Not Found) Cannot POST /php/index.php

Just use the file location in full, like:

$.post('http://www.example.com/directory/php/index.php', {data});

The url in your javascript has to be relative to the current active url in the web browser. The best way to solve this for you is to use a absolute path. Like this:

$.post('/php/index.php', {data});