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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:28:39+00:00 2026-06-18T05:28:39+00:00

how to support JSONP returns in ASP.Net website for getJson calls? var url =

  • 0

how to support JSONP returns in ASP.Net website for getJson calls?

var url = "http://demo.dreamacc.com/TextTable.json?callback=?";
        $.ajax({
            type: 'GET',
            url: url,
            async: false,
            jsonpCallback: 'jsonCallback',
            contentType: "application/json",
            dataType: 'jsonp',
            success: function (ooo) {
                alert('hi');
                alert(ooo);
            },
            error: function () {
                alert('w');
            }
        });

the previous function doesn’t fire the neither the success nor the error function

  • 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-06-18T05:28:40+00:00Added an answer on June 18, 2026 at 5:28 am

    On the server you could write a handler which will return JSONP response:

    public class MyHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            // set the response content type to application/json
            context.Response.ContentType = "application/json";
    
            // generate some JSON that we would like to return to the client
            string json = new JavaScriptSerializer().Serialize(new
            {
                status = "success"
            });
    
            // get the callback query string parameter
            var callback = context.Request["callback"];
            if (!string.IsNullOrEmpty(callback))
            {
                // if the callback parameter is present wrap the JSON
                // into this parameter => convert to JSONP
                json = string.Format("{0}({1})", callback, json);
            }
    
            // write the JSON/JSONP to the response
            context.Response.Write(json);
        }
    
        public bool IsReusable
        {
            get { return true; }
        }
    }
    

    The idea here is that the generic handler will check for the presence of a callback querystring parameter and if specified it will wrap the JSON into this callback.

    Now you could point the $.ajax call to this server side handler:

    var url = "http://demo.dreamacc.com/MyHandler";
    $.ajax({
        type: 'GET',
        url: url,
        jsonp: 'callback',
        dataType: 'jsonp',
        contentType: "application/json",
        dataType: 'jsonp',
        success: function (result) {
            alert(result.success);
        },
        error: function () {
            alert('error');
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET webservice that returns JSON. Now, using jQuery I want to
I am using Rails 2.3 and I decided to provide support for JSONP. Created
I support a .NET 2.0 Winforms application that is fairly widely deployed. On rare
I'm trying to use the geocoding code from here in my ASP.NET MVC 2
I am doing a cross-domain json post utilizing asp.net web api. On my service
Possible Duplicate: File Upload ASP.NET MVC 3.0 I am trying to just print out
I am using a jQuery Ajax control from this site http://abeautifulsite.net/2008/03/jquery-file-tree/ I have it
I'm using gviz_api (google-visualization-python) to build some line charts. http://code.google.com/p/google-visualization-python/ I'e edited a line
I'm using asp.net web forms with Web Api. I can make the call over
Possible Duplicate: OData pagination with WebApi ( $inlinecount ) Since Asp.net WebAPi almost supports

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.