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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:57:26+00:00 2026-05-23T21:57:26+00:00

i’m developing an web application in .net platform. i have wrote an Handler code

  • 0

i’m developing an web application in .net platform.

i have wrote an Handler code that return a JSON object to Javascript (after i request in AJAX).

the Handler code:

var wrapper = new { 
    left = left.ToString(), 
    top = top.ToString(), 
    width = width.ToString(), 
    height = height.ToString() };
context.Response.Write(JsonConvert.SerializeObject(wrapper));

In Javascript, when i do alert, i see that i get an object. and it’s good.
But now i want to parse it to JSON.

when i do JSON.parse(msg); i get an error

“JSON.parse: unexpected character”

when i do jQuery.parseJSON(msg); using jquery-1.6.2, i get this error

jQuery.parseJSON is not a function (i’m using jquery-1.6.2)

What is the problem?

  • 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-23T21:57:27+00:00Added an answer on May 23, 2026 at 9:57 pm

    Try this.

    Create a page called TestPage.aspx like this.

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Test Page</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                $.ajax({
                    url: 'TestPage.aspx/GetDimensions',
                    type: 'POST',
                    contentType: 'application/json',
                    data: '{}',
                    success: function (response) {
                        // Don't forget that the response is wrapped in a
                        //  ".d" object in ASP.NET 3.5 and later.
                        var data = response.d;
                        $('#test-div').animate({
                            left: data.left + 'px',
                            top: data.top + 'px',
                            height: data.height + 'px',
                            width: data.width + 'px'
                        }, 5000, function () {
                            // Animation complete.
                        });
                    }
                });
            });
        </script>
        <style type="text/css">
            #test-div
            {
                background-color:#eee;
                border: 1px solid #ccc;
                border-radius: 5px;
                height: 100px;
                left:0px;
                padding-top: 40px;
                text-align:center;
                top:0px;
                width: 100px;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
    
        <div id="test-div">
        This is a test div
        </div>
    
        </form>
    </body>
    </html>
    

    And on TestPage.aspx.cs, do this

    using System.Web.Services;
    
    public partial class Test1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e){/*page load eent*/}
    
        static int left = 50;
        static int top = 50;
        static int height = 200;
        static int width = 200;
    
        [WebMethod]
        public static object GetDimensions()
        {
            return new
            {
                left = left.ToString(),
                top = top.ToString(),
                width = width.ToString(),
                height = height.ToString()
            };
        }
    }
    

    Hope this helps.

    Courtesy: ASP.NET web services mistake: manual JSON serialization by Dave Ward

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
I used javascript for loading a picture on my website depending on which small

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.