Search code examples
ajaxwindows-phone-7jquery-mobilecordovamustache

Phonegap WP 7.5 mango and AJAX


Thanks to all who was trying to help me with WP8 and AJAX.

Problem in a few words, here is my code in WP8+Phonegap:

document.addEventListener('deviceready', function () {
            jQuery.support.cors = true;
            $.mobile.allowCrossDomainPages = true;
            $.Mustache.load("www/about.txt");
        }, false);

In jquery.mustache.js .load():

function load(url, onComplete) {
    return $.ajax({
            url: url,
            dataType: options.externalTemplateDataType
        }).done(function (templates) {
            $(templates).filter('script').each(function (i, el) {
                add(el.id, $(el).html());
            });

            if ($.isFunction(onComplete)) {
                onComplete();
            }
        });
}

When gets callback it goes to function Add.

It all works on iOS, Android and WP8.

But on WP7.5 it doesn't work. How to fix it?


Solution

  • Answer was simple, in WP8/Phonegap application you must specify full path to a resource:

    $.Mustache.load("www/about.txt");
    

    In WP7/Phonegap application you must NOT specify full path:

    $.Mustache.load("about.txt");
    

    Hope it will help someone.