js ajax receive html

Solutions on MaxInterview for js ajax receive html by the best coders in the world

showing results for - "js ajax receive html"
Tessa
06 Aug 2017
1$.ajax({
2  	type: 'POST',
3  	url: "<Your URL>",
4	contentType: 'application/json; charset=utf-8'
5  	// Set your dataType to either 'html' or 'text'.
6	// Keep in mind: dataType is for receiving,
7	// contentType is for sending
8  	dataType: 'html',
9  	data: { example: 1, id: "0x100"},
10	// Note: the data above is used in sending,
11	// data below is a variables that stores received data
12  	success: function (data){
13     	// Suppose you have an html element, where you want to append 
14     	// the response:
15     	$('#<Your html element id>').html(data);
16  		// .html(data) overwrites existing data
17		// Use .append(data) to add response without overwriting!
18  	}
19});
20