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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:52:47+00:00 2026-05-26T07:52:47+00:00

Invalid JSON issue with asp.net jquery ajax call Hi, I am facing a strange

  • 0

Invalid JSON issue with asp.net jquery ajax call

Hi,

I am facing a strange issue while receiving response for an ajax call when I fire it to page.
I am using jquery to post data to the code behind

Javascript –

var jsonData = { "a": JSON.stringify(obj1),"b": JSON.stringify(obj2)};
jsonData = JSON.stringify(jsonData);

$.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: 'Page.aspx/AjaxCall',
    async: true, cache: true, data: jsonData, dataType: "json",
    success: function (msg) {
        alert('hurray! Success. ' + msg.d);
    },
    error: function (xhr, textstatus, errorThrown) {
        alert('there was an error' + errorThrown);
    }
});

C#

[WebMethod]
public static string AjaxCall(string a, string b)
{
    Dictionary<object, Dictionary<string, object>> x = new Dictionary<object, Dictionary<string, object>>();
    Dictionary<string, object> z = new Dictionary<string, object>();
    Dictionary<object, object> y = new Dictionary<object, object>();
    int u = 0;
    int v = 0;

    // deserialise z class
    try
    {
        if (!string.IsNullOrEmpty(b))
        {
            z = (Dictionary<string, object>)new JavaScriptSerializer().Deserialize(b, typeof(Dictionary<string, object>));

            if (z.ContainsKey("IsProctored"))
                y.Add("BlurCount", z["BlurCount"]);

            if (z.ContainsKey("IsCrossClicked"))
            {
                y.Add("IsCrossClicked", z["IsCrossClicked"]);               
            }
        }
    }
    catch (InvalidOperationException ioe)
    {
        throw new Exception();
    }

    // deserialise items class
    try
    {
        x = (Dictionary<object, Dictionary<string, object>>)
        new JavaScriptSerializer().Deserialize(a, typeof(Dictionary<object, Dictionary<string, object>>));
    }
    catch (InvalidOperationException ioe)
    {
        throw new Exception();
    }

    if (u == 0)
    {
        throw new Exception();
    }

    if (v == 0)
    {
        throw new Exception();
    }

    if (x.Count == 0)
    {
        //throw new Exception();
    }

    try
    {
        // saves the data in backend
        SaveResponse(u, v, x, y);
    }
    catch (Exception ex)
    {
        throw new Exception();
    }

    return "response fired";
}

The error that I get is ‘Invalid JSON’ (in Firebug’s response tab of ajax call). Although it’s straightforward ajax call.

I am kinda confused why this maay be happening because this it works on majority of the cases and fails on some other.

Any idea would be a great help.

thanks!

  • 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-26T07:52:48+00:00Added an answer on May 26, 2026 at 7:52 am

    It was because of some strange issue with Firefox 3.6. I restarted the browser and tested it again and things were working as expected.

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

Sidebar

Related Questions

I'am building simple Ajax application (via jquery). I have strange issue. I found where
I've been getting an 'Invalid JSON' after making a jQuery AJAX Request. This request
I've done the following tests with JSON requests sent to an ASP.NET 2.0 ASMX
Could you help me for resolving this issue. I have one asp.net application, in
I get the following error message when sending an ajax request: Invalid JSON: {html:,jobNum:0}<!DOCTYPE
Trying to decode an invalid encoded utf-8 html page gives different results in python,
I had a Invalid Cross Thread access issue, but a little research and I
I have the following invalid XML file: <?xml version=1.0 encoding=utf-8 ?> <Page num=1 crop_box=0,
I have jQuery.ajax() creating a request to a url (cms2/docman/dir/%id) (%id is a numeric
The following is technically invalid JSON: { color: blue, size: 14 } because 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.