Send Multiple value using ajax code example

Example 1: ajax send multiple data to php

$.ajax({
	url: "/something",
    type: "GET",
    data: {p1: "value1", p2: "value2"}, // multiple data we want to send
    success: function(data){ 
   		console.log(data);
    }
}).done(function(){
    console.log("Success.");
}).fail(function(){
    console.log("An error has occurred.");
}).always(function(){
  	console.log("Complete.");
});

Example 2: javascript ajax receive multiple values

// At the time of writing best bet is to do this:

// Construct a string from your response and separate the items with a comma
// Lets say your request sends response a string like this: '1,2'

$.ajax({
	url: '<myUrl>',
	//data: { "id": id },
	//async: false,
	success: function (data) {
		var response = data.split(",");
		var first = response[0];
      	var second = response[1];
      	// ... etc.
	}
}