Can not call .php files after switching to %postname%

This

$('#content').load("submenu.php");

works just fine with default permalinks

When I switch to %postname% it does not work any more

But, I can still go though to mysite.com/submenu.php and it loads just fine

Did I miss something here?

Topic pre ajax php permalinks Wordpress

Category Web


What I assume is happening is when you are viewing a page with pretty permalinks, your relative URL breaks: submenu.php becomes http://yourdomain.com/pagename/submenu.php

Try using .ajax instead:

$.ajax({ 
    type: "GET",
    url: "http://localhost/submenu.php", 
    data: "cat=32" 
}).success(function(data) {
     $('#content').html(data);
});

This behavior wouldn't happen using the standard URI query because no URI segments are added, therefore the browser would always know to look in the root. Using the ajax function is a much better solution than the load function.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.