mercredi 22 juillet 2015

Ajax call in different web application

I've 2 web applications. I want to make an ajax call from one web application(say Application1) to another web application(say Application2).

I'm doing it like this

  var ajax_url = "http://localhost:50224/common/IsUserOnline";
    $.ajax({
        url: ajax_url,
        dataType: "json",
        type: "POST",
        data: { customerId: '@Model.UserId' },
        success: function (response) {
            var data = response.Data;
            if (data.isUserOnline == false) {
                $("#IsUserActive").val('false');
            }
            else {
                $("#IsUserActive").val('true');
            }
        }
    });
    if ($("#IsUserActive").val() == "false") {
        window.location.href = '@Url.Action("SessionExpired", "Home")';
    }

However i get the following error. No 'Access-Control-Allow-Origin' header is present on the requested resource. Is there a way i can make a hit to Application2 and get the data?

Aucun commentaire:

Enregistrer un commentaire