BreakHead
BreakHead

Reputation: 10672

Unable to consume WCF service by Java Script using XmlHttpRequest

Here is my java script to call WCF service

 function CallWcfAjax() {
          var xmlhttp = new XMLHttpRequest();

           var url = "http://localhost:20949/RestService/tiger/pandey";                    

           // Send the HTTP request
           xmlHttp.open("GET", url, true);
           xmlhttp.send();           

           // Create result handler 
           xmlHttp.onreadystatechange = function X() {                   
               if (xmlHttp.readyState == 4) {
                   alert(xmlHttp.responseText);
               }
           }
       }

if I enter the same URL in browser http://localhost:20949/RestService/tiger/pandey i get a response.

Any idea what wrong I am doing in Java Script?

Thanks

Upvotes: 0

Views: 1492

Answers (1)

Francis
Francis

Reputation: 3383

You variable name is xmlhttp and in the rest of you code, you use xmlHttp. This is a problem.

Upvotes: 1

Related Questions