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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:03:08+00:00 2026-06-11T20:03:08+00:00

Just don’t get it what i’m doing wrong.. i’ve been looking for dozens of

  • 0

Just don’t get it what i’m doing wrong..
i’ve been looking for dozens of similar questions, yet still got misunderstandings…
when i call CallHandler function from JS, i always get ‘Request Failed’ alert.
please help me.

JS/Jquery:

function CallHandler() {
    $.ajax({
        url: "DemoHandler.ashx",
        contentType: "application/json; charset=utf-8",
        type: 'POST',
        dataType: "json",
        data: [{"id": "10000", "name": "bill"},{"id": "10005", "name": "paul"}],
        success: OnComplete,
        error: OnFail
    });
    return false;
}

function OnComplete(result) {
    alert(result);
}
function OnFail(result) {
    alert('Request Failed');
}

asp.net c# code behind:

public void ProcessRequest(HttpContext context)
{
  JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();
  string jsonString = HttpContext.Current.Request.Form["json"];

  List<Employee> emplList = new List<Employee>();
  emplList = jsonSerializer.Deserialize<List<Employee>>(jsonString);

  string resp = "";
  foreach (Employee emp in emplList){
  resp += emp.name + " \\ ";
  }
  context.Response.Write(resp);
}

public class Employee
{
  public string id { get; set; }
  public string name { get; set; }
}
  • 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-11T20:03:10+00:00Added an answer on June 11, 2026 at 8:03 pm

    Try

    data: JSON.stringify([{id: "10000", name: "bill"},{id: "10005", name: "paul"}])
    

    edit I removed the quotes from the property names

    Also, the JSON string needs to be read in other way

    string jsonString = String.Empty;
    
    HttpContext.Current.Request.InputStream.Position = 0;
    using (StreamReader inputStream = new StreamReader(HttpContext.Current.Request.InputStream))
    {
         jsonString = inputStream.ReadToEnd();
    }
    

    An working solution

    public void ProcessRequest(HttpContext context)
    {
        var jsonSerializer = new JavaScriptSerializer();
        var jsonString = String.Empty;
    
        context.Request.InputStream.Position = 0;
        using (var inputStream = new StreamReader(context.Request.InputStream))
        {
            jsonString = inputStream.ReadToEnd();
        }
    
        var emplList = jsonSerializer.Deserialize<List<Employee>>(jsonString);
        var resp = String.Empty;
    
        foreach (var emp in emplList)
        {
            resp += emp.name + " \\ ";
        }
    
        context.Response.ContentType = "application/json";
        context.Response.ContentEncoding = Encoding.UTF8;
        context.Response.Write(jsonSerializer.Serialize(resp));
    }
    
    public class Employee
    {
        public string id { get; set; }
        public string name { get; set; }
    }
    
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just don't get it, and I'm not even sure if I'm looking in
I just don't get it. I got three simple rows for a website. Just
I just don't get it. I have a function to read stemmed strings from
I just don't get it. Any manual is too technical. What are flat and
Maybe I just don't know enough about structs and have been using them blindly
I've got a problem and I just don't know how to solve this (relatively)
I just don't get it: when I use the camera with an intent and
Sry but I just don't understand what is wrong in my syntext, can you
There's something I just don't get regarding config files and dev or prod environments.
I just don't get it where is the problem but here's the error: Fatal

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.