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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:01:05+00:00 2026-06-10T02:01:05+00:00

I am making a call to a handler that returns a json object but

  • 0

I am making a call to a handler that returns a json object but the response is causing the $.ajax() call to hit the error function with no responseText. The handlers response.ContentType is application/json.

The ajax call…

$.ajax({
    url: "http://localhost/_tools/ajax/getInstagramObject.ashx",
    type: 'GET',
    dataType: 'json',
    success: function (msg) {
        alert(msg.length);
    },
    error: function (e) {
        alert(e.responseText);
    }
});

This is the json that the handler returns

{"info":[{"userName":"jamie_cahs","id":"42763829","name":"Jamie Rose","data":[{"images":{"lowResolution":{"url":"http://distilleryimage4.s3.amazonaws.com/de9c1e74bf4511e1abd612313810100a_6.jpg","width":306,"height":306},"thumbnail":{"url":"http://distilleryimage4.s3.amazonaws.com/de9c1e74bf4511e1abd612313810100a_5.jpg","width":150,"height":150},"standardResolution":{"url":"http://distilleryimage4.s3.amazonaws.com/de9c1e74bf4511e1abd612313810100a_7.jpg","width":612,"height":612}},"caption":{"text":"#boston"},"link":"http://instagr.am/p/MUsh6dO9ls/"}]}

and the handler…

public void ProcessRequest(HttpContext context) {
    HttpResponse httpResponse = context.Response;
    httpResponse.ContentType = "application/json";

    var json = new JsonWrapper();

    var users = from user in _instagramPromotionUsersDataContext.instagramPromotionUsers
                select user;

    JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
    foreach (var user in users) {
        HttpWebRequest instagramWebRequest = (HttpWebRequest)WebRequest.Create(string.Format(INSTAGRAM_ENDPOINT, user.id.ToString()));
        instagramWebRequest.Method = WebRequestMethods.Http.Get;
        instagramWebRequest.ContentType = "application/json; charset=utf-8";

        try {
            using(HttpWebResponse instagramWebResponse = (HttpWebResponse) instagramWebRequest.GetResponse()) {
                var dataContractJsonSerializer = new DataContractJsonSerializer(typeof (InstagramObject));
                InstagramObject instagramObject = (InstagramObject) dataContractJsonSerializer.ReadObject(instagramWebResponse.GetResponseStream());

                json.info.Add(new Dictionary<string, object>() {
                    {"userName", user.userName},
                    {"id", user.id.ToString()},
                    {"name", user.name},
                    {"data", instagramObject.data}
                });

            }
        } catch (WebException e) {
            //do nothing just go to next record if exception is thrown
        }
    }

    httpResponse.Write(javaScriptSerializer.Serialize(json));
}
  • 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-10T02:01:06+00:00Added an answer on June 10, 2026 at 2:01 am

    The ajax options needed contentType and I removed the protocol and host from the url.

    Changed $.ajax() to this…

    $.ajax({
        url: "/_tools/ajax/getInstagramObject.ashx",
        type: 'GET',
        dataType: 'json',
        contentType: 'application/json; charset=utf-8',
        success: function (msg) {
            /*if (msg) {
            $('#test').text(msg);
            }*/
            alert(msg.length);
        },
        error: function (e) {
            alert(e.responseText);
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making ajax call like this $(document).ready(function() { var abc = new Array();
When making a function call in Linux (or OS X for that matter), can
I m making call to server using NSURLConnection for iPhone & receiving the response
I'm making call to Alfresco Webscripts which return JSON. I do this using GET
I've got an html page from where Im making this call periodically: function logon(id)
This is the code for my function, in which I am making a call
Hullo, For some reason (that I can't work out) a function that returns an
What's the best practice for making sure that certain ajax calls to certain pages
I'm making the following call in jQuery, using jsonp as my data format, that
I am making a call to a web service, the results of the web

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.