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

  • Home
  • SEARCH
  • 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 6049257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:33:19+00:00 2026-05-23T07:33:19+00:00

Im constructing an array of objects like this: var postData = []; $.each(selectedFields, function

  • 0

Im constructing an array of objects like this:

var postData = [];

$.each(selectedFields, function (index, value) {
    var testTitle = 'testing ' + index;
    postData.push({title: testTitle, title2 : testTitle});        
}

I then post it like this(note that i have tried a number of different aproaches):

$.post('SaveTitlesHandler.ashx', { form : postData }, function (data) {
    console.log(data);
});

I then try to get the data in a handler…

public class SaveTitlesHandler : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        string json = context.Request.Form.ToString();
    }

}

I cant seem to get proper json out of the request. Anyone got any idea?

cheers.

twD

  • 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-23T07:33:20+00:00Added an answer on May 23, 2026 at 7:33 am

    You are not posting JSON. You are using application/x-www-form-urlencoded. So inside the handler you could access individual values:

    public void ProcessRequest(HttpContext context)
    {
        var title1 = context.Request["form[0][title]"];
        var title2 = context.Request["form[0][title2]"];
    
        var title3 = context.Request["form[1][title]"];
        var title4 = context.Request["form[1][title2]"];
    
        ...
    }
    

    If you wanted to POST real JSON you need this:

    $.ajax({
        url: 'SaveTitlesHandler.ashx',
        type: 'POST',
        contentType: 'application/json; charset=utf-8',
        data: JSON.stringify(postData),
        success: function(result) {
            console.log(result);
        }
    });
    

    and then inside the handler read from the request input stream:

    public void ProcessRequest(HttpContext context)
    {
        using (var reader = new StreamReader(context.Request.InputStream))
        {
            string json = reader.ReadToEnd();
        }
    }
    

    The JSON.stringify method converts a javascript object into a JSON string and it is a native method built-in modern browsers. You might also need to include json2.js if you want to support older browsers.

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

Sidebar

Related Questions

Say I have several objects within a class, each of which needs constructing with
So, lets say in my main activity, i have an array declared like this,
I have an associative array (object) of the following construction var menu = new
I'm constructing a method to take in an ArrayList(presumably full of objects) and then
I am currently constructing a Carputer front end and one function that it needs
I have a tree-like object structure that consists of two types of objects: object
I'm trying to write a Linq query which returns an array of objects, with
What is the cleanest way to pass the result of this recursive function back
In JNI I'm constructing a large array by calling SetObjectArrayElement() to insert a java
I'm trying to use this code block of php in C#: $fb->api(array( 'method' =>

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.