0

How to return the function's value only after jquery .load() is finished? What I wanted to mean is something like this. Is there any possible way to do it without using ajax or server side scripts?

function initCalculate() {
    var theFirstResult = getResultPage(1);
}

function getResultPage(value) {
    var $tmpDiv = $('<div>');
    var result = '';
    $tmpDiv.load('result.html #' + value, function () {
        result = $(this).html();
    });
    return result;
}
Arun P Johny
  • 365,836
  • 60
  • 503
  • 504
Nerdar
  • 1,093
  • 2
  • 10
  • 23
  • 1
    you can't do it like that.. instead you should use a callback mechanism to solve it as mentioned in http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call – Arun P Johny Feb 16 '15 at 03:38
  • thank you. understands now. :) – Nerdar Feb 18 '15 at 03:25

0 Answers0