nhanfu / htmljs

HTML render engine and data binding (MVVM)
MIT License
283 stars 48 forks source link

I need help with the ajax calls. #5

Open findborg opened 9 years ago

findborg commented 9 years ago

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.

nhanfu commented 9 years ago

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
    });
findborg commented 9 years ago

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