Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Solution for Use of Webservices in Firefox using Javascript

Solution for Use of Webservices in Firefox using Javascript

Scheduled Pinned Locked Moved ASP.NET
csharpjavascripthtmltoolsxml
4 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abubakarsb
    wrote on last edited by
    #1

    This code has been checked in IE6, IE7 and Firefox and it works perfectly in all of them. Here is the Javascript code which you need to put within <script> tag. var req; var isIE; function initRequest() { if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { isIE = true; req = new ActiveXObject("Microsoft.XMLHTTP"); } } //url will be Web Service URL. function CallWebService(url,params) { initRequest(); req.onreadystatechange = processRequest; req.open("POST", url, true); if(params!=null)req.setRequestHeader("Content-length", params.length); req.setRequestHeader("Connection", "close"); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); req.send(params); } function processRequest() { if (req.readyState == 4) { if (req.status == 200) { var message = req.responseXML; //Result in XML. // Accessing the tag 'string' is name of node var myNodes=message.getElementsByTagName("string"); // Getting actual result of webservice and saving it in a variable which can be use anywhere in page. // alert("Result of webservice is : "+myNodes.item(0).firstChild.nodeValue);// Checking result var serviceValue=myNodes.item(0).firstChild.nodeValue; } } } Here is the Html code which you can put within <body> tag. <%--<input type="button" value="Call .NET Web Service!" onclick="CallWebService('http://pathOfYourServer/nameOfWebService.asmx/testWebService1',null)" /> <input type="button" value="Call .NET Web Service with parameters!" onclick="CallWebService('http://pathOfYourServer/nameOfWebService.asmx/testWebService2','a=Michael&b=5')" /> You can also pass dynamic values like below CallWebService("http://pathOfYourServer/nameOfWebService.asmx/testWebService2","name1="+value1+"&name2="+value2+"&name3="+value3+"") where name(1,2,3) is the name of your variable and value(1,2,3) is value of respective variable. Note: Number of variables you pass in above line must be same as you defined in the definition of webservice. Here is the webservice code which you need to enter in your webservice file. using System; using System.Web; using System.Collections; using System.Web.Services; using System.Web.Services.Protocols; /// /// Summary description for WebService /// [WebService(Namespace = "http://tempuri.org/")] [

    M 1 Reply Last reply
    0
    • A Abubakarsb

      This code has been checked in IE6, IE7 and Firefox and it works perfectly in all of them. Here is the Javascript code which you need to put within <script> tag. var req; var isIE; function initRequest() { if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { isIE = true; req = new ActiveXObject("Microsoft.XMLHTTP"); } } //url will be Web Service URL. function CallWebService(url,params) { initRequest(); req.onreadystatechange = processRequest; req.open("POST", url, true); if(params!=null)req.setRequestHeader("Content-length", params.length); req.setRequestHeader("Connection", "close"); req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); req.send(params); } function processRequest() { if (req.readyState == 4) { if (req.status == 200) { var message = req.responseXML; //Result in XML. // Accessing the tag 'string' is name of node var myNodes=message.getElementsByTagName("string"); // Getting actual result of webservice and saving it in a variable which can be use anywhere in page. // alert("Result of webservice is : "+myNodes.item(0).firstChild.nodeValue);// Checking result var serviceValue=myNodes.item(0).firstChild.nodeValue; } } } Here is the Html code which you can put within <body> tag. <%--<input type="button" value="Call .NET Web Service!" onclick="CallWebService('http://pathOfYourServer/nameOfWebService.asmx/testWebService1',null)" /> <input type="button" value="Call .NET Web Service with parameters!" onclick="CallWebService('http://pathOfYourServer/nameOfWebService.asmx/testWebService2','a=Michael&b=5')" /> You can also pass dynamic values like below CallWebService("http://pathOfYourServer/nameOfWebService.asmx/testWebService2","name1="+value1+"&name2="+value2+"&name3="+value3+"") where name(1,2,3) is the name of your variable and value(1,2,3) is value of respective variable. Note: Number of variables you pass in above line must be same as you defined in the definition of webservice. Here is the webservice code which you need to enter in your webservice file. using System; using System.Web; using System.Collections; using System.Web.Services; using System.Web.Services.Protocols; /// /// Summary description for WebService /// [WebService(Namespace = "http://tempuri.org/")] [

      M Offline
      M Offline
      Michael Sync
      wrote on last edited by
      #2

      Cool..... :) I glad to hear that your problem is solved.... As I suggest you earlier, if you are working for large Ajax-enabled project, you may probably want to use Javascript Ajax framework (eg: prototype js library) or ASP.NET Ajax...

      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

      A 1 Reply Last reply
      0
      • M Michael Sync

        Cool..... :) I glad to hear that your problem is solved.... As I suggest you earlier, if you are working for large Ajax-enabled project, you may probably want to use Javascript Ajax framework (eg: prototype js library) or ASP.NET Ajax...

        Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

        A Offline
        A Offline
        Abubakarsb
        wrote on last edited by
        #3

        I already voted your message. I posted a new message in forumn, may be you already read it if u didn't I am repeating here again. if you know its answer please reply its answer. Thanks. QUESTION I want to use embedded Window Media Player functions like stop(), pause() in Firefox. Does anyone have an idea? I checked following two ways. They are working good in IE6 and IE7 but not in Firefox. (1) document.Player.controls.pause(); (2) document.getElementById("Player").controls.pause(); Please tell me a solution in Firefox. Thanks. Abuabakr

        M 1 Reply Last reply
        0
        • A Abubakarsb

          I already voted your message. I posted a new message in forumn, may be you already read it if u didn't I am repeating here again. if you know its answer please reply its answer. Thanks. QUESTION I want to use embedded Window Media Player functions like stop(), pause() in Firefox. Does anyone have an idea? I checked following two ways. They are working good in IE6 and IE7 but not in Firefox. (1) document.Player.controls.pause(); (2) document.getElementById("Player").controls.pause(); Please tell me a solution in Firefox. Thanks. Abuabakr

          M Offline
          M Offline
          Michael Sync
          wrote on last edited by
          #4

          Why do you wanna add this from Javascript? If you are embedding Windows Media Player Object in WebPage, all buttons (play,pause,stop and etc) are already included in that object. So, I don't think you need to add this duplicated features from Javascript.. You can check the screenshot here.

          <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" name="mediaplayer1" ShowStatusBar="true" EnableContextMenu="false" autostart="false" width="320" height="240" loop="false" src="MyVideo.wmv" />

          Ref: Embedding Windows Media Player into a web page

          Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups