0
$(function () {
    var apiEndpoint = "https://www.myaddress.com/api/";

    var getVersion = $.ajax({
        url: apiEndpoint + "version/",
        dataType: "JSON",
        username: "myuser",
        type: "GET",
        password: "mypass"
    });

    getVersion.done(function (version) {
        alert("HEY!!!!!!!!!!");
    });

    getVersion.fail(function () {
        alert("I'm not invoked either!");
    });
});

This code works fine on Chrome on my desktop, but when calling the page on iPhone no alerts show. Any ideas why this is?

I have a feeling it is because of the https://, but why is this only a problem on iPhone and how can I resolve it?

jskidd3
  • 4,609
  • 15
  • 63
  • 127
  • does username or password have an @ symbol in it? – Todd Dec 19 '14 at 01:58
  • have you tried url encoding? – Todd Dec 19 '14 at 01:59
  • @Todd No I haven't tried URL encoding (not sure how), and yes the password does have an @ symbol in it. – jskidd3 Dec 19 '14 at 10:09
  • was the issue resolved when you enabled http auth on the endpoint? – Todd Dec 19 '14 at 15:36
  • @Todd Originally I thought that would be the case, but no it wasn't, it was actually solved by removing username and password properties and using this instead: http://stackoverflow.com/a/19729716/2273902 – jskidd3 Dec 19 '14 at 15:45
  • yeah, I was going to suggest you try the `beforeSend` option to add auth header if you hadn't resolved the problem. You should post your solution as an answer to your own question and mark it as correct, so its "closed". Also, you should upvote the reply you referenced above as well as its question! glad you got it fixed! – Todd Dec 19 '14 at 16:18

1 Answers1

-1

Try using this code:

$(function () {
var apiEndpoint = "https://www.myaddress.com/api/";

var getVersion = $.ajax({
    url: apiEndpoint + "version/",
    dataType: "JSONP",
    username: "myuser",
    type: "GET",
    password: "mypass",
    async:false,
    cache:false,
});

getVersion.done(function (version) {
    alert("HEY!!!!!!!!!!");
    });

getVersion.fail(function () {
    alert("I'm not invoked either!");
    });
});

async and cache set false just to make sure that data is not fetched from cache.

Rahul Munjal
  • 2,551
  • 2
  • 15
  • 35
  • this is not really an answer. This belongs in the comments. Answers should have specific advice on how to solve a given issue, and not ask a question themselves. – Todd Dec 19 '14 at 16:13