htmljs icon indicating copy to clipboard operation
htmljs copied to clipboard

I need help with the ajax calls.

Open findborg opened this issue 10 years ago • 2 comments

I know that this should be very simple. But, I just can not figure out the ajax. All I am trying to do is use a link to call say buttons.php into a div on the current page called winDow. Please show me an example of this. Note** Then I want to be able to call other pages like typo.php, components.php, etc. I figured out how to do the router which is fine. But, I want to separate the sections into other pages and just bring them in via ajax.

findborg avatar Mar 09 '15 06:03 findborg

Hi Findborg, You can try the ajax code below.

html.ajax('components.php')
    .done(function (pageContent) {
      html('#myDiv').text(pageContent); // append the content to your div
    }).fail(function (xhr) {
      console.log(xhr.statusText);          // log the error, statusText is usually used
    });

nhanfu avatar Mar 10 '15 03:03 nhanfu

Oh, I see. I could not figure out how to configure the done (function). I will give it a try.

findborg avatar Mar 10 '15 03:03 findborg