SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,048
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Relative path problem jQuery

    Hi,

    I have a relative path issue when using jQuery in that I am using the same ajax function sitewide and I don't know how I can send a request to a PHP file without needing to provide the full absolute path.

    For example, the below code works at top level, but will not work if called from inside a sub folder.

    Code JavaScript:
    $.get("./ajax/locations.php", { input: $(this).val(), standardajax: '2' },function(data)
    {
    // code here
    }

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Zaggs View Post
    For example, the below code works at top level, but will not work if called from inside a sub folder.
    You can make it relative from the root directory instead. "/ajax/locations.php"
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •