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 545653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:47:04+00:00 2026-05-13T10:47:04+00:00

Got kind of a tricky problem. I’m working on a project where we need

  • 0

Got kind of a tricky problem.

I’m working on a project where we need to allow receipt printouts when users check out on our site at a kiosk. For reasons relating to drivers and formatting, I am using COM automation with Word to handle printing out the receipts. I’ve wrapped this code up in a web service that runs on a local machine.

The plan was to put a simple jQuery ajax call in the page html to the url of the local machine running the web service. This ajax call contains a json object of the order, which is deserialized by the web service and printed out. Works fine if I use localhost, however in production I will run afoul of no cross domain ajax calls rule.

A proxy will not work because the code running on the website cannot contact the local web service running the printing service. After poking around on the web, I discovered that using JSONP may be a solution to this but I can’t figure out how to make it work. Most tutorials assume that you are trying to get some remote data rather than just simply posting data. The printing web service returns void.

How do I configure my web service (asmx) to work with JSONP and what would my jQuery code look like? Currently it looks something like this:

function printReceipt(data) {
   $.ajax({
       type: "POST",
       url: "http://192.9.200.165/ContestWebService/Service1.asmx/PrintOrderReceiptJson",
       data: data,
       dataType: "json",
       contentType: "application/json; charset=utf-8",
       error: function(xhr, msg) { alert(xhr.statusText); }
    });
}

Any simpler alternatives to JSONP, or any other possible solutions I may have not considered would be helpful as well.

  • 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-13T10:47:04+00:00Added an answer on May 13, 2026 at 10:47 am

    JSONP simply adds a script tag to the head section and thus is limited only to GET requests. In order to configure your asmx web service to handle JSONP you will need to handle serialization manually:

    [WebMethod]
    [ScriptMethod(UseHttpGet=true, ResponseFormat=ResponseFormat.Json)]
    public string Foo()
    {
        var json = new JavaScriptSerializer().Serialize(new 
        {
            Prop1 = "some property",
        });
        string jsoncallback = HttpContext.Current.Request["jsoncallback"];
        return string.Format("{0}({1})", jsoncallback, json);
    }
    

    And the client side:

    $.getJSON("http://192.9.200.165/ContestWebService/Service1.asmx/PrintOrderReceiptJson?jsoncallback=?",
        function(data) {
            alert(data);
        });
    

    Another alternative for cross domain AJAX calls is to use Flash.

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

Sidebar

Related Questions

I've got kind of a tricky question, I already searched every related question on
I got a kind of weird problem: I want to fade images. The Code
I've got some kind of community website, there are about 40.000 users in database
I've got a modal popup (using ModalPopupExtender) working in a kind of master/detail view
I've got a school project, kind of huge, and only a few days left,
I have got two models, User and Event. I need two kind of relationship
Ive got some kind of a problem here. When I try this function, it
UPDATE 2: OK, got it kind of working by changing: $loginUrl = $facebook->getLoginUrl(array( 'canvas'
So I've got kind of an interesting problem. I have a wicket page that
I've got kind of an odd problem. Regardless of what I do to the

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.