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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:21:18+00:00 2026-05-16T10:21:18+00:00

$.post(‘somescript.php’, { data: $(‘#myInputField’).val() }, function(replyData) { 1) Is the second argument of this

  • 0
$.post('somescript.php', { data: $('#myInputField').val() },
    function(replyData) {

1)
Is the second argument of this $.post method – in json?

OR

2)
Is the second argument of this $.post method a query string?

Thanks in advance,
MEM

Note: If this question doesn’t make sense, please, knowing why (it doesn’t make sense) may also help and, be taken as an valid answer as well.

  • 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-16T10:21:18+00:00Added an answer on May 16, 2026 at 10:21 am

    In general both ways are in practice very close. The function $.post or $.ajax will encode the data posted in the same way. If you want to post JSON data you should additionally encode the data value with some JSON encoder. See How do I build a JSON object to send to an AJAX WebService? as an example ($.post is a short form of $.ajax, so all which described with $.ajax and correct also for $.post)

    $.post('somescript.php', { data: JSON.stringify($('#myInputField').val()) }, ...);
    

    In the code above I use JSON.stringify from http://www.json.org/js.html.

    UPDATED: After your questions in the comment I hope I understand more which you want to know. So jQuery.post don’t makes any JSON encoding of data for you for and input parameters (the second parameter of jQuery.post). So it send the data always exactly in the same way. You can add additional “json” parameter (the last dataType parameter) to the $.post call, but this will not change how the data will be encoded.

    The question “should I send JSON data to the server or not?” is independent on $.post and you should answer on the question yourself depend on the requirement existing in your project. Sometime it is the question of the architecture of your solution. Sometime you have to choose one special way.

    In case of Microsoft ASMX Web Service for example there exist some important restriction. For example you want to deliver JSON data from the web service to be able to work easy with the data in JavaScript. So you want to have a method on the server side which have some input parameters and returns JSON as output. In case ASMX Web Service you must sent all input parameter to the web service method as JSON encoded data to be able to return JSON data from the web service, but ASMX Web Service decode/encode the data for you and you don’t need manually encode/decode JSON on the server side.

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

Sidebar

Related Questions

$.post('testeUpdate.php', 'autocomplete', function(dadosResposta) { $('#ns-nome').val(dadosResposta.nsName); $('#ns-endereco').val(dadosResposta.nsAddress); }, json); I'm trying to understand this. So,
my post looks like this: $.post('/ajaxvalidate/1', {nid: nid}, function(data) { I get the Uncaught
$.post(../js.php, {state: state}, function(data) { return data; }); Here's my jquery code. Like you
This post shows how to axiomatise a length function for Z3's built-in lists. However,
The Post looks like this. $data = array('icd9' => $icd9, 'cpt' => $cpt, 'session_id'=>
first post ever here I'm trying to replicate this sort of JSON object so
This post from F# News states that F# can inline a function passed as
$.post('ajax_ceneizbaze.php', function(cenovnik){ if(cenovnik){ cenastr=cenovnik.cenastrana; cenadinamika=cenovnik.cenadinamika; cenabaza=cenovnik.cenabaza; cenakorpa = cenovnik.cenakorpa; cenacms = cenovnik.cenacms; inkrementodrzavanje =
This post is a follow-up of this answered question: Best method for storing a
post.php?replyto=username&othervariable=value For example, if I click a link with this url, then I want

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.