Skip to content
Nikolai Manek edited this page Oct 8, 2015 · 3 revisions

HOME

JQuery Examples

POST

// AJAX Request: My API (https://api.apphera.com/api/v1/keywords/1)

$.ajax({
	url: "https://api.apphera.com/api/v1/keywords/1",
	type: "POST",
	timeout: 30000,

	// HTTP Headers: https://api.apphera.com/api/v1/keywords/1

	headers:{
		"api-token":"3d8a2bc7-e8a3-436e-b67d-e1c30086d8d52a4e2768-2957-4b8b-a493-80980has987",
		"Content-Type":"application/json",
	},

	// Request Body: https://api.apphera.com/api/v1/keywords/1

	data:" { \"keyword\":{ \"name\" : \"Porsche\" , \"tracks\" : [\"twitter\",\"facebook\", \"instagram\", \"search\"], \"organization_id\" : 1234, \"markets\" : [\"en-US\", \"th-TH\"] } }\n",

	// Success Callback: https://api.apphera.com/api/v1/keywords/1

	success:function(data, textStatus) {
		console.log("Received response HTTP "+textStatus+" (https://api.apphera.com/api/v1/keywords/1)");
		console.log(data);
	},

	// Error Callback: https://api.apphera.com/api/v1/keywords/1

	error:function(jqXHR, textStatus, errorThrown) {
		console.log("Error during request "+textStatus+" (https://api.apphera.com/api/v1/keywords/1)");
		console.log(errorThrown);
	},
});

GET

// AJAX Request: My API (https://api.apphera.com/api/v1/keywords/1)

$.ajax({
	url: "https://api.apphera.com/api/v1/keywords/1",
	type: "GET",
	timeout: 30000,

	// HTTP Headers: https://api.apphera.com/api/v1/keywords/1

	headers:{
		"api-token":"3d8a2bc7-e8a3-436e-b67d-e1c30086d8d52a4e2768-2957-4b8b-a493-80980has987",
		"Content-Type":"application/json",
	},

	// Success Callback: https://api.apphera.com/api/v1/keywords/1

	success:function(data, textStatus) {
		console.log("Received response HTTP "+textStatus+" (https://api.apphera.com/api/v1/keywords/1)");
		console.log(data);
	},

	// Error Callback: https://api.apphera.com/api/v1/keywords/1

	error:function(jqXHR, textStatus, errorThrown) {
		console.log("Error during request "+textStatus+" (https://api.apphera.com/api/v1/keywords/1)");
		console.log(errorThrown);
	},
});
Clone this wiki locally