0 votes
in Education by (1.7m points)
I have following code and I want to get data from service. I have set everything from what I get Google.

function checkLicense() {

debugger

try {

    var _name = "aaa-bcs-edt"; //location.host;

    $.ajax({

        type: "POST",

        url: "http://mdc.abc.com/LicenseWebService.svc/IsLicenseValidByName",

        data: '{"DName":"' + _name + '"}',

        contentType: "application/json; charset=utf-8",

        crossDomain: true,

        dataType: "json",

        async: false,

        success: function (msg) {

            debugger

            var data = msg.d;

            if (data == "success") {

                licenseactivated = "success";

            }

            else {

                licenseactivated = "Fail";

            }

        },

        error: function (XMLHttpRequest, textStatus, errorThrown) {

            debugger

            alert(errorThrown.toString());

        }

    });

} catch (err) {

    debugger

    alert(err.message.toString);

}

Head:

<head>

    <title>Create Purchase Order</title>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta>

    <meta>

    <meta>

</head>

Here is the console log with error:

Can anybody please suggest me?

JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by (1.7m points)
You need to enable cors headers in the server side.

http://www.codeproject.com/Articles/845474/Enabling-CORS-in-WCF
...