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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:34:40+00:00 2026-05-16T12:34:40+00:00

Please consider the following HTML: <input type=’text’ id=’name’/> <option id=’option’> <select value=’1′>hi</select> <select value=’2′>bye</select>

  • 0

Please consider the following HTML:

<input type='text' id='name'/>
<option id='option'>
  <select value='1'>hi</select>
  <select value='2'>bye</select>
</option>
<input type='text' id='date'/>

This is a very simple form used to get search criteria from a user. I need to submit this search criteria to the server with an AJAX call. What is the best data type/structure to use to do this? And why?

I’m currently thinking a string vs. JSON object. So, I’ll either pass

"John|2|2010-10-10" 

to the server or I’ll pass

{"name":"John","option":2,"date":"2010-10-10"}

Maybe there is some other creative way to deal with search criteria? This criteria is being shot to the server only one time, it doesn’t come back to JS.

  • 1 1 Answer
  • 2 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-16T12:34:41+00:00Added an answer on May 16, 2026 at 12:34 pm

    If you wrap your HTML in a <form> tag, you can easily use the $.serializeArray() function in jQuery.

    http://api.jquery.com/serializeArray/

    $.serializeArray() creates a JavaScript object literal in the form of:

    [ {name: a, value:1}, {name: b, value: 2}, ...]

    This is done, I believe, because your form could have multiple fields with the same name. An associative array wouldn’t support this.

    I’d recommend that you send your data to your server in a JSON format (using serializeArray or some other method) rather than a plain string. JSON is more standardized and can handle escaping characters. If you’re using pipe-delimited strings, then you have to take into account when a user wants to submit a pipe (|) to the server. Then you get into situations where you have crazy delimiters like ||** between values. (I’ve seen this — it’s ugly!). Stick with JSON.

    If you’d prefer a more querystring-like format (e.g. a=1&b=2&c=3) that you can include in your request body, you can use $.serialize().

    http://api.jquery.com/serialize/

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

Sidebar

Related Questions

Please consider the following HTML: <td> Some Text <table>.....</table> </td> I need to manipulate
Please consider the following view: <p>Count <span data-bind=text: unreadCount()>&nbsp;</span></p> <div data-bind='template: { name: conversationTemplate,
Please consider following sample query SELECT * FROM subscriber WHERE subscription_date>DATE(NOW()-INTERVAL 10 DAY) My
Please consider the following tweets table: tweet_id user_id text ---------------------------- 1 1 lorem ipsum
Please consider the following code: #include <iostream> #include <typeinfo> template< typename Type > void
Please consider the following code, <form action=index.php method=post name=adminForm enctype=multipart/form-data> <input type=hidden name=showtime[] id=showtime_1
Consider the following html: <div class=image> <img src=sample.png/> <div class=text> Text of variable length
Please consider the following string $text = Dat foo 13.45 and $600 bar {baz:70}
Please consider the following: DECLARE @xml XML SET @xml = '<Capture> <Data><DataType>Card Number</DataType><Value>1234567898765</Value></Data> <Data><DataType>Expiry
Please consider the following HTML with styling. <div style=border: 1px solid;height: 600px;> <button id=create_new_estimate

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.