theNoobProgrammer
theNoobProgrammer

Reputation: 932

web service not working on safari

I have created a web service and call it from my javascript using ajax. It works on internet explorer to some extent but fails when i call try to run it on safari or firefox. Does anyone know why?

Here is my js code:

function GetTopApps() {
    var serviceUrl = "http://localhost:2975/GetData.asmx?wsdl";

    var soapMessage ='<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><HomeScreenApps xmlns="http://tempuri.org/" /></soap:Body></soap:Envelope>'


    $.ajax({
        url: serviceUrl,
        type: "post",
        datatype: "xml",
        data: soapMessage,
        complete: GenerateList,
        contentType: "text/xml; charset=\"utf-8\""
    });

    return false;
}

function GenerateList(xmlHttpRequest, status) {
    $(xmlHttpRequest.responseXML)
                .find('HomeScreenAppsResult')
                .each(function () {
                 parseXML(xmlHttpRequest);
            });
        }

function parseXML(xmlHttpRequest) {
    var xmlDoc = xmlHttpRequest.responseXML;
    var appIdArray = xmlDoc.getElementsByTagName('application_id');
    var appNameArray = xmlDoc.getElementsByTagName('application_name');
    var appRatingArray = xmlDoc.getElementsByTagName('average_rating');

    var appCount = appIdArray.length;
    var appList = document.getElementById('TopApps');

    var htmlString = "<small><small><small><small><small><small><small><ul data-role='listview' data-filter='false' id='list'>";

    for (i = 0; i < 5; i++) {

        htmlString = htmlString + "<li><a id='" + appIdArray[i].xml + "' onclick='AppSelected(id);'>";
        htmlString = htmlString + "<img src='' alt='Logo' class='ListAppLogo'>";
        htmlString = htmlString + "<h3>" + appNameArray[i].xml + "</h3>";
        htmlString = htmlString + "<p>" + appRatingArray[i].xml + ".0/5.0</p>";
        htmlString = htmlString + "<input  type='hidden' value='" + appIdArray[i].xml + "'></a></li>";
    }

    htmlString = htmlString + "</ul></small></small></small></small></small></small></small>";
    appList.innerHTML = htmlString;
    $('#list').listview();

}

Upvotes: 0

Views: 1727

Answers (2)

khanna..abhishek
khanna..abhishek

Reputation: 59

Safari is more secure than IE or Chrome. You would easily be able to run on chrome or IE because safari needs certificate of that server whose service you are calling. ensure that you create certificate for that server if you wanted to run that on mac or Iphone

Upvotes: 0

TJHeuvel
TJHeuvel

Reputation: 12608

You can find out yourself by using a Javascript debugger such as Firebug for Firefox, or the built-in web inspector for Safari.

First check your javascript error log and console for any parsing errors, if there are none use breakpoints to step through your code to see how it executes. If you find anything specific which you dont understand feel free to ask about that.

Also consider the error might be in your webservice, not where you call it.

Upvotes: 1

Related Questions