Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6717211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:49:33+00:00 2026-05-26T08:49:33+00:00

I’ve the following code: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> <html xmlns=http://www.w3.org/1999/xhtml>

  • 0

I’ve the following code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" language="javascript" src="script/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" >

        var varType;
        var varUrl;
        var varData;
        var varContentType;
        var varDataType;
        var varProcessData;          
        //Generic function to call AXMX/WCF  Service        
        function CallService() 
        {
                $.ajax({
                    type        : varType, //GET or POST or PUT or DELETE verb
                    url         : varUrl, cache: false // Location of the service
                    data        : varData, //Data sent to server
                    contentType : varContentType, // content type sent to server
                    dataType    : varDataType, //Expected data format from server
                    processdata : varProcessData, //True or False
                    success     : function(msg) {//On Successfull service call
                    ServiceSucceeded(msg);                    
                    },
                    error: ServiceFailed// When Service call fails
                });
        }

        function ServiceSucceeded(result) {//When service call is sucessful
            var ProvinceDDL = document.getElementById("ddlProvince");
            for (j = ProvinceDDL.options.length - 1; j >= 0; j--) { ProvinceDDL.remove(j); }
            var resultObject = null;
            if (varDataType == "json")
            {
                if (varUrl.indexOf(".asmx/") > 0) {
                 resultObject = result.d; // Constructed object name will be object.d //Button 1
                }
                else if (varType == "GET") {resultObject = result;}
                else {
                    // Constructed object name will be object.[ServiceName]Result // Button 2 & 3
                    resultObject = result.GetProvinceResult;
                    if (resultObject == null) {
                        //WCF Service with multiple output paramaetrs //Button 4
                        resultObject = result.GetProvinceAndBrowserResult.ProvinceInfo;
                    }

                }

                 for (i = 0; i < resultObject.length; i++) {
                     var opt = document.createElement("option"); opt.text = resultObject[i];
                     ProvinceDDL.options.add(opt)
                 }

                 if (result.GetProvinceAndBrowserResult != null) 
                    { //WCF Service with multiple output paramaetrs //Button 4
                     $("#divMulti").html(result.GetProvinceAndBrowserResult.BrowserInfo);
                     }
                 else
                     $("#divMulti").html("click button 4");


             }
             else if (varDataType == "xml") {//Parse XML based result;
                $(result).find("GetProvinceXMLResult").children().each(function() {
                var opt = document.createElement("option"); opt.text = $(this).text();
                ProvinceDDL.options.add(opt)        
                });
            }

             varType=null;varUrl = null;varData = null;varContentType = null;varDataType = null;varProcessData = null;     
        }
        function ServiceFailed(result) {
            alert('Service call failed: ' + result.status);
            varType = null; varUrl = null; varData = null; varContentType = null; varDataType = null; varProcessData = null;     
        }

        function CountryProvinceWebService() {
            varType = "POST";
            varUrl = "http://localhost:1752/HTTPServiceJquery/service/CountryProvinceWebService.asmx/GetProvince";
            varData = '{"Country": "' + $('#ddlCountry').val() + '"}';
            varContentType = "application/json; charset=utf-8";
            varDataType = "json";
            varProcessData = true;
            CallService();
        }

        function CountryProvinceWCFJSON() {
            varType = "POST";
            varUrl = "http://localhost:1752/HTTPServiceJquery/service/CountryProvinceWCFService.svc/GetProvince";
            varData = '{"Country": "' + $('#ddlCountry').val() + '"}';
            varContentType = "application/json; charset=utf-8";
            varDataType = "json";
            varProcessData = true;
            CallService();
        }

        function CountryProvinceWCFXML() {
            varType = "POST";
            varUrl = "http://localhost:1752/HTTPServiceJquery/service/CountryProvinceWCFService.svc/GetProvinceXML";
            varData = '{"Country": "' + $('#ddlCountry').val() + '"}';
            varContentType = "application/json; charset=utf-8"; 
            varDataType = "xml"; 
            varProcessData = true;
            CallService();
        }

        function CountryProvinceWCFJSONMulti() {
            var browser = "";
            if (jQuery.browser.mozilla == true) browser="firefox"
            else if(jQuery.browser.msie == true) browser = "ie"

            varType = "POST";
            varUrl = "http://localhost:1752/HTTPServiceJquery/service/CountryProvinceWCFService.svc/GetProvinceAndBrowser";
            //We are passing multiple paramers to the service in json format {"Country" : "india", "Browser":"ie"}
            varData = '{"Country": "' + $('#ddlCountry').val() + '","Browser": "' + browser + '"}';
            varContentType = "application/json; charset=utf-8";
            varDataType = "json";
            varProcessData = true;
            CallService();
        }

        function CountryProvinceWCFJSONGet() {
            varType = "GET";
            varUrl = "http://localhost:1752/HTTPServiceJquery/service/CountryProvinceWCFService.svc/GetProvinceGET?Country=" +$('#ddlCountry').val();
            varContentType = "application/json; charset=utf-8";
            varDataType = "json";
            varProcessData = false;
            CallService();
        }


        function CountryProvinceWCFREST() {
            varType = "GET";
            varUrl = "http://localhost:1752/HTTPServiceJquery/service/CountryProvinceWCFService.svc/GetProvinceREST/" + $('#ddlCountry').val();            
            varContentType = "application/json; charset=utf-8";
            varDataType = "json";
            varProcessData = false;
            CallService();
        }


        function ShowImage() {
            // WCF service is used to stream the image. Service url is assigned to src attribute of the image
            // Basically a GET request
            $("#image1").attr('src','http://localhost:1752/HTTPServiceJquery/service/CountryProvinceWCFService.svc/GetPicture');

        }
    </script>
</head>
<body>
    <form id="form1" runat="server">    
    <div><b>
    <p>JQuery , WCF , JSON , XML , AJAX , ASMX , REST</p><br />
    </b>

        <div>

            <div style="background-color:ButtonShadow;width:500px;">
            <hr /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            Country: &nbsp;

            <select id="ddlCountry">                   
                    <option id='usa'>USA</option>
                    <option value='india'>India</option>
             </select>


            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            Provinces:&nbsp;             
              <select id="ddlProvince" name="ddlProvince">
               </select><br />
               <center><div id="divMulti" style="color:White">&nbsp;</div></center>
                <br /><br />
            </div>              
        </div>
<div>
<table><tr><td valign="top">
        <table border="1" width="500px" height="400px" cellpadding="5" cellspacing="5" 
            style="background-color: #F0F0F0">
            <tr>
                    <td align="left">1) Call ASMX Web service using JQuery </td>
                    <td><input type="button" value="Invoke" id="btnInvokeWebService" onclick="CountryProvinceWebService();" /> </td>
            </tr>
            <tr>
                    <td align="left">2) Call WCF service using JQuery and get data in JSON Format </td>
                    <td><input type="button" value="Invoke" id="btnInvokeWCFJSON" onclick="CountryProvinceWCFJSON();" /> </td>
            </tr>     
            <tr>
                    <td align="left">3) Call WCF service using JQuery and get data in XML Format </td>
                    <td><input type="button" value="Invoke" id="btnInvokeWCFXML" onclick="CountryProvinceWCFXML();" /> </td>
            </tr>
            <tr>
                    <td align="left">4)  Call WCF service using JQuery and get data in JSON Format (pass multiple input parameters) & ( Get multiple objects as output using DataContract)</td>
                    <td><input type="button" value="Invoke" id="btnInvokeWCFMJSONMultiple" onclick="CountryProvinceWCFJSONMulti();" /> </td>
            </tr> 
            <tr>
                    <td align="left">5) Call WCF service using JQuery[ Get Method] and get data in JSON Format</td>
                    <td><input type="button" value="Invoke" id="Button1" onclick="CountryProvinceWCFJSONGet();" /> </td>
            </tr>             
            <tr>
                    <td align="left">6) Call REST based WCF service using JQuery</td>
                     <td><input type="button" value="Invoke" id="Button2" onclick="CountryProvinceWCFREST();" /> </td>
            </tr>      
            <tr>
                    <td align="left">7) Stream an image through WCF and display it in browser</td>
                     <td><input type="button" value="Invoke" id="Button3" onclick="ShowImage();" /> </td>
            </tr>                                                                   
        </table>

        </td>
        <td>
        <img src="" id="image1" width="500" height="400" visible="false"  />
        </td>

        </tr></table>
             <br />  <br />  
             <hr />   
             <br />           
</div>
    </div>
    </form>
</body>
</html>

When I host this page with the service on localhost. All the WCF Service works properly.
But if I open this page without hosting it in localhost, it doesn’t work.

How can I host this page in another place and call my WCF Service?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:49:34+00:00Added an answer on May 26, 2026 at 8:49 am

    Change the http://localhost:1752/ to where you host your service.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.