Htaccess interfering with Javascript?

I’ve been trying to get the qtip to work generating a tool tip, I know there’s nothing wrong with the javascript as when that’s tried separately with a stand-alone PHP script for the “source data” it works fine. The script executes as I added an alert just to check if the script is running

The htaccess file is

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

When I try the URL for the source data direct, that loads (though gives errors as there is no $_POST data. Do I need to add an exception to stop the redirecting for the “source file”?

The PHP side is MVC based on: hxxps://www.youtube.com/watch?v=Aw28-krO7ZM

show your javascript code first

The javascript is below:

 $("a.user[title]").qtip({
        show: "click",
        hide: false,
       
        content: {
          text: function(event, api){
            $.ajax({
              url: "http://localhost/universal_empires/api/ajax_test",
              data: {
                id: $(this).data("id"),
                name: $(this).text()
              },
              type: "POST"
            })
            
            .done(function(html) {
              api.set("content.text", html)
            })
            .fail(function(xhr, status, error) {
              api.set("content.text", status + ": " + error)
            })
            return "Loading...";
          },
          button: "Close"
        }
      });
 alert('Testing');
      $("a.user").on("click", function(e){
        e.preventDefault();
      });

The htaccess looks normal and correct. Plus, if you can type in the URL and get the expected result, then that seems a good indication that it’s working fine.

Hi SP!

Tooltips are pretty easy although you can get fancy with some jQuery (like using AJAX to fetch content for a tooltip container). Oh, well, that is my tip-of-the-day. I went to your youtube link but couldn’t spare the time to view over half an hour for a video on something as simple as a tooltip (yeah, my bad). Of course, I don’t understand “(t)he PHP side is MVC …” as tooltips are basic HTML with some CSS thrown in for good measure (enough of my whining about that, eh?).

Your mod_rewrite code is just fine (albeit I’d replace ^(.+)$ with .? and $1 with %{REQUEST_URI} but that a personal preference in coding). In fact, what you’ve done is make index.php your 404 handler script!

Your RewriteCond statements are the exceptions (the !-f one) which will prevent redirecting from index.php (assuming index.php exists). That said, mod_rewrite cannot interact with PHP, HTML or JavaScript and, because you’re retaining any pre-existing query string, that will be unaffected (although it generated the $_GET array, not the $_POST array).

Regards,

DK

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.