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

How To Send JSON Objects In JQuery With An Ajax Request

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

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:

Twinkle <span>Product Strategist</span>
Written By
Twinkle Product Strategist

Twinkle is an experienced business and marketing consultant of the mobile app industry. She advocates perfect branding to the latest tech releases. She is passionate about writing well-researched reports to help the app owners and the mobile app industry audience. Also, she has a vibrant touch that goes well in her writing as well.

mobile app development

Progressive Web Apps: Why You No Longer Need Websites

4 min read  

To turn your simple and basic website into a not-so-basic Progressive Web App or simply speaking into a PWA is actually a smart move to follow. But unfortunately, many are still not aware of this little trick that can help their business a great deal.But before we proceed towards the reasons on

mobile app development

Why You Need To Transform Website Into An Android Or iOS App

7 min read  

Websites are a valuable resource that supports businesses by providing a steady sales platform to the customers. Overall, a website can be referred to as a cost-efficient tool for communication between a company and its clients. But is using a website for your business enough or you need to

mobile app development

React Native: A Note on Rearchitectural Revitalization

4 min read  

The cross-platform mobile development framework was announced at React.js conf 2015. Since then, React Native has come a long way in which the programming language was extensively used by developers to unleash their skill sets into the world of mobile development.Facebook launched the React Nati

mobile app development

How To Increase Device Space in your iPhones

4 min read  

iPhones’ camera quality has improved impressively in the past few decades to such an extent that some extra-talented geeks are ditching their DSLRs. That’s the beauty iPhones have garnered over the years. Well, lots of photos, the time lapse Instagram videos, the hefty KB of downloaded f