Arda
Arda

Reputation: 10929

easy way of posting the result of php file into javascript function

function check () {
    var result;
        $.post('file.php', function(data) {
                    result = data;
                    });
                    return result;

    }

I can't seem to get the result since its function(data) is asynchronous... how can I achieve that in a different way?

what I want to do is to get the echoed result from file.php via check() function call in javascript...

Upvotes: 0

Views: 39

Answers (1)

Dave Long
Dave Long

Reputation: 794

you could use the ajax jQuery api to send the request : http://api.jquery.com/jQuery.ajax/

and set the async property to false.

Upvotes: 1

Related Questions