jQuery Mobile Ajax json错误

this error is driving me crazy.

While using jquery 2.0.3 it works, when I change to jQuery 1.10.2 it doesn't !!! I need to use jQuery 1.10 in order to use jquery mobile panel widget I don't know what is wrong, the json is a valid jso I test it.

Here is the code: (I changed the html for an alert)

$(document).on('pageinit', "#news_list", function () {
    $.ajax({
        type: "GET",
        crossDomain: true,
        url: "http://app.virtual-competiciones.es/api/news/getnews?num=20",
        headers: { "Accept-Encoding": "gzip" },
        dataType: 'json',
        cache: false,
        success: function (data) {
            var result = data;
                        alert("ok");
        },
        error: function (xhr, status, error) {
            alert("ERROR - xhr.status: " + xhr.status + '
xhr.responseText: ' + xhr.responseText + '
xhr.statusText: ' + xhr.statusText + '
Error: ' + error + '
Status: ' + status);
        }

    });
    return false;
});

The error I'm getting is undefined (No Transport)

I'm going to answer my question so other people doesn't have to spen hours on the same thing.

While using jQUery 2.0.3 you don't need to add anything else but the code I posted, if you use jQuery 1.10.2 you nee to add this:

<script>
$(document).on("mobileinit",function() {
    $.support.cors = true;
});        
</script>

In the head section between the jQuery and jQUery Mobile scripts. This allows to make a CrossDomain call.

Maybe is easy but since I didn't use it in version 2.0.3 it wasn't that obvious for me. I hope this help other people.

I ran into the same problem today. Safari browser -using Ipad- was failing to submit the form and displaying this error message:

Cannot open page Safari can not open the page because the address is invalid

I upgraded my JQ from 10.2 to JQuery v2.0.3 (I'm also using Jquery Mobile 1.4.0-rc.1)

I've been using href="javascipt:void(0);" for empty anchor tags. This was causing the JQ ajax calls to fail.

<a href="javascipt:void(0);" onclick="submitDynamicForm('@rndId');" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-icon-check ui-btn-icon-left ui-btn gl">Save</a>

I removed the href and it starts working fine. it was initiating another http call for the javascript:void(0);.

$.ajax({
    url: url,
    type: 'post',
    dataType: "json",
    contentType: "application/json; charset=utf-8",
    //processData: false,
    data: jsonData,
    //crossDomain: true,
    headers: { "Timezone": getTimezone() },
    success: function (response) {
        console.log(response.data);
    },
    error: function (xhr, status, error) {
        //  console.log('ajax done - error');
        console.log("ERROR - xhr.status: " + xhr.status + '
xhr.responseText: ' + xhr.responseText + '
xhr.statusText: ' + xhr.statusText + '
Error: ' + error + '
Status: ' + status);
    }
});