legnaleurc / qbtd

Qt-based BitTorrent Daemon
4 stars 2 forks source link

Dynamic Ajax base URL #6

Open johnroyer opened 12 years ago

johnroyer commented 12 years ago

Ajax query url is now static. Can not change with CodeIgniter site_url().

Find a way to make javascript query URL dynamic.

legnaleurc commented 12 years ago

Maybe the URL shortcut helps: /path/do.cgi -> http://somehost/path/do.cgi

johnroyer commented 12 years ago

Shortcut does help. But CodeIgniter URI routing method cause browser parse error.

For example, if we need to pass parameter "user-id" to controller "user", full URL would like:

    http://path.to.site/index.php/user/user-id

String after "index.php" is actually a parameter. But browser parse it as a path. So when we give a shortcut to another page "user/login/", browser will add it after the whole URL, not "index.php" :

    http://path.to.site/index.php/user/user-id/user/login/

site_url() in CodeIgniter can create the URL exclude controller and parameter after "index.php". I use it to give javascript the absolute URL needed in commit e4f3592e663b41d83fdc63fa172c4c272d928d24. Still finding a better way.

legnaleurc commented 12 years ago

Try "/index.php/user/login/" ?

johnroyer commented 12 years ago

It works only if the CodeIgniter is at the root of this domain. Else, you still get errors.