How to call from jQuery to get data?

Hi,wondering what the best approach to this would be.setting up a simple side-panel that will contain information/help on the current page. i want to grab the content based on the form id (currentForm.id)in the various forms in the client script, the following code is present…

loadjs.ready("head", function () {
    // Client script
    $('#result-data-content').html("Future home of Context help & information section." + "<br><br>Form: " + currentForm.id);
});

my question is should i use something similar to this as an Api_Action to grab the content to replace the above code?, hopefully non-blocking so the loads while the call grabs the data and displays?

$.get(ew.getApiUrl("getPageInfo") + '/' + currentForm.id) 
       .done(function (data) {
                  $('#result-data-content').html(data);
      })
});

EndResult:

loadjs.ready("head", function () {
    // Client script
$.get(ew.getApiUrl("getPageInfo") + '/' + currentForm.id) 
       .done(function (data) {
                  $('#result-data-content').html(data);
      })
});

function getPageInfo() would return formmatted content from a table ready for displaythoughts appreciated.

formatted that nicely!i have a working mockupuserfn.js

function getPageContextHelp(pageID){   
    loadjs.ready("head", function() {      
        $.get(ew.getApiUrl("getContextHelp") + '/' + pageID)
        .done(function (data) {
            $('#result-data-content').html(data);
        }).fail(function (data) {
            $('#result-data-content').html('content not available. '+ pageID);
        });                                        
    }); 
}

client script on the various pages:

loadjs.ready("head", function () {
    // Client script
       getPageContextHelp(currentForm.id);
});

so the side-panel content gets updated from the getPageContextHelp(pageId) function instead of the client side script…

You should remove loadjs.ready(“head”, function() { and }); from your getPageContextHelp().

yes, your right, thanks, i just did a c&p