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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:19:07+00:00 2026-06-05T02:19:07+00:00

I have an aspx page that returns valid JSON – however when called via

  • 0

I have an aspx page that returns valid JSON – however when called via JQUERY I can see in Fiddler that the JSON is returned but an error is thrown [Object error].

   protected void Page_Load(object sender, EventArgs e)
   {
    string json = "{\"name\":\"Joe\"}";
    Response.ClearHeaders();
    Response.ClearContent();
    Response.Clear();
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.ContentType = "application/json";
    Response.ContentEncoding = Encoding.UTF8;
    Response.Write(json);
    Response.End();
   }

The html page consuming this page is in a different domain, and I am using jsonp.

function jsonpCallback(response){
    alert(response.data);
}

$(document).ready(function(){ 

            $.ajax({
                url: 'http://localhost:30413/getprice.aspx',
                dataType: 'jsonp',
                error: function(xhr, status, error) {
                    alert(error);
                },
                success: jsonpCallback
            });

}); 

When the aspx page is requested valid JSON is returned to the browser, when the JQUERY call is made JSON is returned but the callback function is not called and an Expected “;” JS error then an [Object error] message is displayed. Below are the request and responses made.

I’ve tried every variation of the request with the same result. I am using the request JQUERY sample below because it works in the last sample shown below.

GET http://localhost:30413/price.aspx?callback=jQuery17105556924406763212_1338876162569&_=1338876162581 HTTP/1.1
Accept: application/javascript, */*;q=0.8
Referer: http://alpha.tigerdirect.com/applications/b2b/varinfo.asp
Accept-Language: en-US
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Accept-Encoding: gzip, deflate
Host: localhost:30413
Connection: Keep-Alive
Pragma: no-cache
Cookie: ASP.NET_SessionId=d4pje2hgm2beznslfpp4pii5



HTTP/1.1 200 OK
Server: ASP.NET Development Server/10.0.0.0
Date: Tue, 05 Jun 2012 06:02:42 GMT
X-AspNet-Version: 4.0.30319
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Content-Type: application/json; charset=utf-8
Content-Length: 14
Connection: Close

{"name":"Joe"}

This sample works

function jsonpCallback(response){
    alert(response.data);
}
$(document).ready(function(){ 
        $.ajax({
            url: 'http://api.bitbucket.org/1.0/repositories/retroviz/webformsthemeswitcher/src/tip/.hgignore',
            dataType: 'jsonp',
            error: function(xhr, status, error) {
                alert(error);
            },
            success: jsonpCallback
        });
}); 
  • 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-05T02:19:08+00:00Added an answer on June 5, 2026 at 2:19 am

    Change url in ajax to url: http://localhost:30413/getprice.aspx?callback=?

    And

    if(Request.QueryString['callback']!=null){
        string callback = Request.QueryString['callback'];
        string json = "{\"name\":\"Joe\"}";
        Response.ClearHeaders();
        Response.ClearContent();
        Response.Clear();
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ContentType = "application/json";
        Response.ContentEncoding = Encoding.UTF8;
        Response.Write(callback + "(" + json + ")");
        Response.End();
    }
    

    In jsop, we wrap the response in callback function call. Just like we call a function in javascript.

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

Sidebar

Related Questions

I have a web project that has a page called editemployee.aspx. The code behind
I have an .aspx page that generates thumbnails. It takes an ID and returns
I have a aspx page that has a UpdatePanel and a asp timer. the
I have a .aspx page that loads three separate .ascx controls to represent adding,
I have a aspx page (details page) that needs to be loaded in a
I have an aspx page that contains a checkbox, and a button. The button
I have an aspx page that has a @Page directive which points to a
I have an aspx page that I want to convert to an HttpHandler ,
I have created one aspx Page from that i need to access the property
I have an ASP.net aspx page that's composed of 3 iframes. One for 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.