jquery - How do i load content from .php files with AJAX? -


im using ajax , history.js load content separate pages index-page. reason can load .html-pages - how make function load .php-pages?

is solution add extensions in in var = urlpath? other ideas?

// ajax load onklik $('body').on('click', 'a', function(e) {     var urlpath = $(this).attr('href');     var title = $(this).text();      history.pushstate({urlpath: urlpath}, title, urlpath);     $("#content").load(urlpath);           return false;  });  

edit:

i using links no extension example loading page 'about.html':

<a href="/about">about</a> 

which generates url in browser when testing locally:

http://localhost/about 

thats ok, nothing happens when try loading .php-page fx 'home.php' same way - nothing gets loaded. seems ajax / history.js breaks somehow.

but - if add extension .php in link page 'home.php', page loads via ajax .html-pages:

<a href="/home.php">about</a> 

however link add extension .php in browser on local test:

http://localhost/home.php 

so know if history.js accepts .html files when working ajax, or missing here?

your function auto load url attibute href in tag a

you must modify line php file

var urlpath = $(this).attr('href'); 

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -