praveen rapelli

praveen rapelli

  • NA
  • 28
  • 39.5k

How to call webservice using html javascript which supports all browsers

Jun 22 2011 12:49 AM
Question:I am calling webservice using html javascript ,it works in all browsers in local system(intranet)
when i upload this in online ,its not working .When i use webservice.htc file in html ,it works in internet explorer properly
but remaining browsers like (firefox,opera,google crome) not supporting.so please tell me the solution to work all browsers properly.


This is webservice i am using:

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections.Generic
Imports System
Imports System.IO
Imports System.Collections
Imports System.Web.Script.Services

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> _
Public Class intellisense
    Inherits System.Web.Services.WebService

    <WebMethod()> _

   Public Function GetCustomers(ByVal prefixText As String, ByVal flag As String) As String


         str2=prefixText **flag;
     

        Return str2

    End Function

End Class

This is html file i am using:

<html>
   <head>
       <title>Consume Count Service</title>
       <script type="text/javascript" language="javascript" >

 function outputResult(){

var xmlhttp = null;
alert(xmlhttp);
if (window.XMLHttpRequest) {
  xmlhttp = new XMLHttpRequest();
  if ( typeof xmlhttp.overrideMimeType != 'undefined') {
    xmlhttp.overrideMimeType('text/xml');
  }
} else if (window.ActiveXObject) {
  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  alert('Perhaps your browser does not support xmlhttprequests?');
}
str='hello';
flag='world';

var url= "http://xyz.example.com/intellisense.asmx/GetCustomers?prefixText="+str+"&flag="+flag;

        xmlHttp.open("GET",url,false);
        xmlHttp.send();
             var myString = xmlHttp.responseText;
             alert(myString);
xmlhttp.onreadystatechange = function() {
  if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
 
    // do something with the results
  } else {
    // wait for the call to complete
  
  }
};

 var myString=xmlHttp.responseText;
                                                                                                                      
}

</script>
</head>
<body onload="outputResult()"> 
</body>
</html>

Answers (2)