Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Aug 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add Service Reference inside function

    hello jscript developers,

    I want to add one service reference inside a function ,how can i do that.
    For example: http://dev.virtualearth.net/REST/v1/Locations?query=
    is one service can I add reference this inside a function.

    function Service()
    {
    //here I want to add service reference
    }

    thanks

    @murali

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    Your question is quite unclear. I know Service References from Visual Studio, where you can add such references to "encapsulate" your service calls. You're wrong if you expect this to happen in Javascript.

    You can, of course, specify a "service reference" as a string. But this depends on what you want to do with it after you added it.

  • #3
    New Coder
    Join Date
    Aug 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi service reference in the sense

    for eg I want to use Bing map api using jscript, I need to add like this

    <script type="text/javascript" src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>

    like this I want to add inside a Javascript Function

  • #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,981
    Thanks
    56
    Thanked 557 Times in 554 Posts
    you mean like this?
    Code:
    function Service()
    {
    var scr=document.createElement("script");
    scr.type="text/javascript";
    scr.src="https://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0";
    document.body.appendChild(scr);
    }

  • #5
    New Coder
    Join Date
    Aug 2013
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes,In this way.

    is it necessary to append child here to body?..can I add reference with out referring body of the document?. because I need to use the Javascript only

    thanks for reply

  • #6
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by jscriptuser View Post
    is it necessary to append child here to body?..can I add reference with out referring body of the document?
    All JavaScript needs to be appended to the body of the page if you want it to run. If you don't attach it then it will not even download.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •