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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:20:01+00:00 2026-05-18T02:20:01+00:00

i want to send a json string from a html webpage using javascript to

  • 0

i want to send a json string from a html webpage using javascript to a WCF.. is there any good tutorial for that?

this is the code i am using

<head> 
   <title>Test</title> 
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> 
   <script type="text/javascript" src="http://www.json.org/json2.js"></script> 
   <script type="text/javascript"> 
     $(function() { 
      JSONStringer json = new JSONStringer()

                      .object()   
                      .key("cno").value("2000")
                      .key("cname").value("HI")
                      .key("cmail").value("HI")
                      .key("cphno").value("9292")
                      .key("cmailtype").value("Home")
                      .key("cphnotype").value("Office")
                      .key("clientno").value("1")

                    .endObject();
       var dat = JSON.stringify(json.serializeArray()); 

       alert("I am about to POST this:\n\n" + dat); 

       $.post( 
         frm.attr("action"), 
         dat, 
         function(data) { 
           alert("Response: " + data); 
         } 
       ); 
     }); 
   </script> 
</head> 

let me know where i have to post it to a particular service.. something like specifying the URL

  • 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-18T02:20:02+00:00Added an answer on May 18, 2026 at 2:20 am

    I think you are mixing up java with javascript. Despite their names they are not related to each other in any way. As far as I know, JSONStringer doesn’t exist in javascript nor jquery. JSON stands for JavaScript Object Notation, so that means it is very native to the javscript languages (with some subtle differences). Since it’s so close it is very easy to parse Json in javascript.

    Also, javascript is a dynamically typed language so supplying the type as you did normally results in a parse error. Use firebug or the Chrome console when your code doesn’t work. You will see an error when the browser was unable to parse your code.

    for the serialization you probably want to use (in a browser that supports JSON and/or with json2.js)

    var dat = JSON.stringify({
      cno: 2000,
      cname: 'HI',
      cmail: 'HI',
      cphno: '9292',
      cmailtype: 'home',
      cphnotype: 'Office',
      clientno: 1
    });
    

    The url goes where you have put frm.attr("action"). I don’t see where you create the frm object. I don’t think you need a JQuery object for that, document.getElementById is supported in all major browsers and I bet it is faster too.

    var myForm = document.getElementById('myformid');
    $.post( 
      myForm.action, 
      dat, 
      function(data) { 
        alert('Response: ' + data); 
      } 
    ); 
    

    Also as far as I know, postdata has to be in query parameter format so perhaps you need to put something like

    'myData=' + dat,
    

    Copy/pasting code from the web can get things started quickly but a lot of javascript programmers forget that you have to understand the language first. Don’t just blindly copy code, try to understand what happens. Try to solve problems first without a library and discover where you actually need a library.

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

Sidebar

Related Questions

I want to send email from a Ruby application. Is there a call in
I'm using XStream and JETTISON's Stax JSON serializer to send/receive messages to/from JSON javascripts
Just a quick question. I want to send data from Javascript to a PHP
I want so send every week an update by email. But Im afraid that
I want to send an array constructed in javascript with the selected values of
I just want to send SMS from my web application in PHP. Can anyone
I am using a RequestBuilder in GWT (1.6) that successfully sends a String (formatted
I'm using json +jquery on client side. I want to disable all buttons found
For testing purposes I want send mail to my localhost user account rather than
I want to send a message to a thread and handle it in 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.