Question

What I want to do is:-

Sending a GET request to php page. with some arguments. receiving data in json format. then returning result to a callback function(to show the process progress.)

In jquery it looks like this:-

$j.get(ajax_url, {action: 'index', prev: prev}, doIndexHandleResults, "json");

How I can do the same in YUI3?

Était-ce utile?

La solution

You can use the io module: http://yuilibrary.com/yui/docs/io/

Example:

YUI().use('io', function (Y) {
    Y.io('/root/www/appConfig.json', {
        on: {
            start: function () {
                Y.log('start');
            },
            success: function (id, o) {
                var json = Y.JSON.parse(o.responseText);
                Y.log(json);
            },
            failure: function () {
                Y.log('failure');
            }
        },
        context: this
    });
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top