views:

14

answers:

0

I made a wcf service and it hosted on IIS 7 . Now i made a local html file with following code

    function CallWcfAjax() {

        try {

            // PROCEED ONLY IF OBJECT IS NOT BUSY
            if (xmlHttp.readyState === 4 || xmlHttp.readyState === 0) {
                // PASS SERVICE URL
                var url = "http://jai31/gmservice/GMService.svc/ajaxEndpoint/";

//var url = "http://ws.geonames.org/countryCodeJSON?formatted=true&lat=47.03&lng=10.2&style=full"; url = url + "LoginUser/"; url = url +document.getElementById("userName").value + "/"; url = url +document.getElementById("pwd").value; alert(url); //url = url + document.getElementById("userName").value + "/" + document.getElementById("pwd").value; // EXECUTE THE PAGE ON THE SERVER AND PASS QUERYSTRING

                xmlHttp.open("GET", url, true);

                xmlHttp.setRequestHeader("Content-type","application/json");
 xmlHttp.setRequestHeader("Access-Control-Allow-Origin","http://jai31.hclt.corp.hcl.in/gmservice/");
                // MAKE CALL
                xmlHttp.send(url);
                // DEFINE METHOD TO HANDLE THE RESPONSE
                xmlHttp.onreadystatechange = handleresponse


            }
            else {
                // IF CONNECTION IS BUSY, WAIT AND RETRY
                setTimeout('CallWcfAjax', 5000);
            }
        } catch (e) {

        }
    }

    function handleresponse() {
        try {

writeMessage("handleresponse",xmlHttp.readyState);

            // MOVE FORWARD IF TRANSACTION COMPLETE
            if (xmlHttp.readyState == 4) {
                // STATUS OF 200 INDICATES COMPLETED CORRECTLY

writeMessage("handleresponse",xmlHttp.status); if (xmlHttp.status == 200) {

                    // WILL HOLD THE XML DOCUMENT
                    var xmldoc;
                    if (window.ActiveXObject) { // INTERNET EXPLORER
                        xmldoc = new ActiveXObject("Microsoft.XMLDOM");
                        xmldoc.async = "false";
                        //                             xmldoc.loadXML(xmlHttp.responseText); 
                        result.innerText = xmlHttp.responseText;

writeMessage("handleresponse",xmlHttp.responseText); } else { // OTHER BROWSERS alert(xmlHttp.responseText); result.innerText = xmlHttp.responseText; } } } } catch (e) { } }

Now this work perfectly in IE but in chrome and other browser its doesn't show data. I checked on Fiddler. Request header

GET /gmservice/GMService.svc/ajaxEndpoint/GetAllApplication HTTP/1.1 Host: jai31.hclt.corp.hcl.in Connection: keep-alive Origin: null Accept: / User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.41 Safari/534.7 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

and resoponse header is

HTTP/1.1 200 OK Cache-Control: private Content-Length: 152 Content-Type: application/json; charset=utf-8 Server: Microsoft-IIS/7.5 X-AspNet-Version: 2.0.50727 X-Powered-By: ASP.NET Access-Control-Allow-Origin: http://jai31.hclt.corp.hcl.in/gmservice/ Date: Wed, 27 Oct 2010 08:49:18 GMT

{"GetAllApplicationResult":[{"AppID":4,"AppName":"geominder","ImageURL":null,"Rating":5},

I googled on it and found origin is showing problem in chrome or browser but i am still not find solution. Plz help me out? where i am wrong?