craig craig - 3 months ago 20
Javascript Question

Append a php file with jquery

i have a file which echoes out data from a database.

I wish to have a load more button which appends this file so that it will keep loading the rest of the results.

The php page works fine but need help with the jquery...

have used this else where for a json return but dont think this is needed for this.

So i am trying this:

$("#loadmore").click(function () {

In essence, this works but it appends 'includes/loadmorebuilds.php' as just that. I simply appends those words and not the file.

Any help on this?

Many thanks!


You could use $.ajax to get content from file to be appended into DOM. One important thing is that you should use Relative PATH to your web root on url parameter in $.ajax

So it will become like this

$('#loadmore').click(function() {
       url: '/relative/path/to/your/script',
       success: function(html) {

And make sure you should be able to access your script on