GET and Post data from server using Cordova JQuery $.ajax() .

Get and post request are basically used to fetch response from server so here are the following steps to achieve this,

1.we need to add following two header files into server side Php file.

header(‘Access-Control-Allow-Methods: GET,POST,PATCH,PUT,DELETE,OPTIONS’);

2.we need to call jquery$.ajax() and passes all the essential detials

example of sending POST request type are as follow.

alert(“reached here 1”);
varemail = $(“#username1”).val();
varpassword = $(“#password1”).val();
varfirst_name = $(“#f_name”).val();
varlast_name = $(“#l_name”).val();
alert(“reached here 2”);
varformData = “first_name=”+first_name+”&last_name=”+last_name+”&email=”+ email+”&password=”+password;
url: “”,
type: “POST”,
success: function(response) {
alert(“Success “+response);
error: function(response) {
alert(“Err “+response);
// window.location.href = “homepage.html”;