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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:11:37+00:00 2026-06-07T00:11:37+00:00

I am attempting to send a json message from a custom application to a

  • 0

I am attempting to send a json message from a custom application to a web page. The json message is being returned, and appears to be valid, but it is not causing the success function to trigger. I am currently using jquery-1.4.4.js, previously I was using jquery-latest.js as hosted on jquery.com. Using that version I received an error of “parseerror”, but with 1.4.4 i don’t receive a success or failure.

My code is as follows:

On the web page:

<script>
$(document).ready(function () {
    $.ajax({url: "http://localhost:8080/callback=?",

            dataType: "json",
            success: function(data) 
            {
                alert("reply received");
            },
            error: function(data, error) 
            {
                alert("error: " + error);
            }
        });
});
</script>

The json message I am receiving back (as viewed in Chrome’s network panel)

[{"name":"John"},{"name":"Mike"}]

And in my C# application the code is:

string response = "[{\"name\":\"John\"},{\"name\":\"Mike\"}]";

request.ContentType = "application/json";
webserver.SendToBrowser(response, request);

and ..

public void SendToBrowser(string data, Classes.HTTPRequest request)
    {
        int numBytes = 0;
        byte[] bData = Encoding.ASCII.GetBytes(data); 
        try
        {
            string header = "";
            header += "HTTP/1.1 200 OK\r\n";
            header += "Server: MyServer\r\n";
            header += "Content-Length: " + bData.Length.ToString() + "\r\n";
            header += "Content-Language: en\n\r";
            header += "Content-Type: " + request.ContentType + "\r\n";
            header += "Connection: close\r\n\r\n";

            Byte[] headerBytes = Encoding.ASCII.GetBytes(header);

            if (request.Socket.Connected)
            {

                request.Socket.Send(headerBytes, headerBytes.Length, 0);

                if ((numBytes = request.Socket.Send(bData, bData.Length, 0)) == -1)
                    Console.WriteLine("Socket Error cannot Send Packet");
                else
                {
                    Console.WriteLine("No. of bytes sent {0}", numBytes);
                }
            }
            else
                Console.WriteLine("Connection Dropped....");
        }
        catch (Exception  e)
        {
            Console.WriteLine("Error Occurred : {0} ", e );
        }
        request.Socket.Close();
    }

Any help much appreciated!

  • 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-07T00:11:38+00:00Added an answer on June 7, 2026 at 12:11 am

    JSONP is not magic.

    Your server needs to follow the JSONP protocol and read the callback= parameter.

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

Sidebar

Related Questions

I'm attempting to send a .proto message from an iPhone application to a Java
I am attempting to send a Point-to-Point JMS message from an oracle database stored
I am attempting to send a message via sockets from VBA. I have made
I am attempting to send a javascript array to my web server for an
I'm attempting to use Redmon http://www.winimage.com/misc/redmon/ to send print jobs to a custom C#
I'm attempting to send an HTTP POST to a Rails 3 Application. Currently all
I am attempting to send statuses to appFabric via a service bus from a
I am attempting to use JSON to send data between the browser and my
I'm attempting to send a JSON encoded MongoDB object back in my HTTP response.
I am attempting to send mail through my gmail account from a Dedicated Godaddy

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.