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

Top Companies

01.
InMobi
Singapore
02.
Dot Com Infoway
New York, USA
03.
M&C Saatchi Mobile
New York City, USA
04.
Techmagnate
New Delhi, India
05.
Fetch
London, UK
View full report
Updated On
August 29, 2018 04:06 PM
4 min read

Latest Articles

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:

Akash Singh Chauhan
Written By
Akash Singh Chauhan

Akash Singh Chauhan is a senior writer at MobileAppDaily and he mainly covers all the latest happenings and tweaks in mobile app technology. Being an Engineering graduate he is always compelled to the technology and tries to discover new trends in the tech world. Along with any tech news he also never misses a single episode of ‘Dragon Ball’.

How To

How To Get A Verified Badge On Your Instagram Account

Vikram Khajuria 5 min read  

Instagram is an ideal platform to share all your buzz activities and the cool pictures that you definitely click on any given day. The video-sharing social networking company has ticked all the right boxes in terms of offering the best deal of its feature-rich platform.But there was one thing th

How To

How To Publish Your First App On Google Play

Neha Baluni 4 min read  

If you are someone anyhow related to app development industry, you must be well aware of the knowledge it takes to either develop or publish your app on the Google Play Store. Of course, the things are not much technical but to be on safer side, it is important to know all the aspects well enough.&n

How To

Knowledge That Matters: How To Clear The Browsing History

Neha Baluni 4 min read  

Web browsers use cache to make browsing experience faster for the users. That means whenever you use a browser, it save some information from the web to help a page load easily to reduce the loading time. The process over a considerable time period adds cookies and cache to your device. This makes i

How To

How To Improve Your Mobile App Security? Here Is The Guide

Vikram Khajuria 7 min read  

In this digitized world, mobile apps have virtually become part of our lives. From the alarm clock to booking a cab for office and from ordering grocery in the evening to late night texts, we all are covered under the umbrella of mobile apps. So, it becomes very crucial that we trust the platform on