How To Send JSON Objects In JQuery With An Ajax Request - MobileAppDaily
How To

How To Send JSON Objects In JQuery With An Ajax Request

Know about the five kinds of parameters that are accepted by AJAX request

https://dk2dyle8k4h9a.cloudfront.net/How To Send JSON Objects In JQuery With An Ajax Request

In this article, we will be telling you how you can send JSON Objects with an Ajax Request (in JQuery) with a short coding tutorial. We will also be clearing out some basics related to sending JSON objects with Ajax requests so keep on reading to find out.

JQuery is a most widely known client-side scripting language that is cross-platform and is a library that acts as a wrapper of JavaScript which supports AJAX, DOM, effects, and events as well. JQuery is powered by one simple syntax that further provides support for Ajax application, Event Handling and easier navigation etc.

What is JSON

JSON stands for JavaScript Object Notation, a term that can be defined as a basic format which is used for data interchange. It is a very lightweight format that is also simple to be written and read by the humans.

The Java Script Object Notation is entirely platform independent format and has a structure that is quite similar to a few other languages.  

In JSON there are basically two different structures which are:

  • An ordered list of values like a Boolean value, enclosed in double quotes.
  • A collection of key-value pairs known as objects.

Basic Syntax of JSON -

{

key : value,

key : value

}

AJAX Requests

The AJAX Request only accepts five kinds of parameters which are:

  1. Data: This is the parameter that we use to assign the JSON data to take the request data along the Ajax request.
  2. URL: This is the for the URL that the AJAX request has to be submitted to.
  3. type: This represents the whether the type of the request is PUT, GET or POST.
  4. dataType: This is for representing the expected data type from the response after the request's data has been processed.
  5. success: The parameter represents the function that is called once the Ajax request is complete.

This is the example of a AJAX Request -

jQuery.ajax(

{

url : getPostData.asp,

type: 'POST',

dataType : "json",

data: {"name":"JSON_Request"},

success:function(data) { alert(data); },

error: function() {alert(data); }

}

);

Stay tuned with us on more updates on JQuery with us by clicking on the ‘Subscribe’ button.

Read More About:

Vikram Khajuria
Written By Vikram Khajuria

Jack of all trades. Covering the journalism field, Vikram writes at MobileAppDaily and keeps surfing the trends to understand tech and inventions better. Don’t forget his driving skills, he is a professional car rallyist. Life has just got better. Breathe it!!

Top Companies

InMobi
Singapore
Dot Com Infoway
New York, USA
M&C Saatchi Mobile
New York City, USA
Techmagnate
New Delhi, India
Fetch
London, UK
View full report

Latest Articles

Join our global community 135K Followers
How To

How To Gain Maximum User Engagement On Instagram With IGTV?

Twinkle Kalkandha 4 min read  

Instagram is one of the most popular social media platforms and IGTV is its long-form video feature. The IGTV is a platform on which Instagram has invested a lot of time, as well as resources. And why not? Videos have proven to be a great mode of user engagement, even better than pictures and text.

How To

How To Resolve "Screen Overlay Detected" Glitch

Vikram Khajuria 5 min read  

The smartphone has become the best friend for many of us. More than half of the time of the day, we are engaged with our smartphones. From calling to sending messages and from playing games to book a cab, we are pinned to our smartphones constantly. So, it becomes very important that we experience s

How To

Is Your YouTube Not Working? Find A Fix Here

Vikram Khajuria 4 min read  

YouTube is the world’s best video-sharing website located in California. The online video website has garnered a lot of popularity over the years and now sit at the top of the list of similar services.As per the data of Statista, the number of YouTube viewers will jump from 1.47 billion in

How To

How To Maximize Your App Revenue This Christmas

Tanya Singh 4 min read  

Well, guess what? It's that time of the year again! The holiday season is in its full swing, and this is the time during which a majority of businesses are looking forward to increasing their sales. This includes businesses from different industry verticals and the Web, as well as mobile app dev