Jak číst html ajax

Příklady kódu

3
0

ajax si html odpověď

//your jquery code will be like this:
$.ajax({
      type: 'POST',
      url: $url,
      data: new FormData(this),
      dataType: 'json',
      contentType: false,
      processData:false,//this is a must
      success: function(response){ 
      		$('your_selector').html(response);
      }
});

//php code will be like this
echo '<div>some html code</div>';
die();
0
0

js ajax přijímat html

$.ajax({
  	type: 'POST',
  	url: "<Your URL>",
	contentType: 'application/json; charset=utf-8'
  	// Set your dataType to either 'html' or 'text'.
	// Keep in mind: dataType is for receiving,
	// contentType is for sending
  	dataType: 'html',
  	data: { example: 1, id: "0x100"},
	// Note: the data above is used in sending,
	// data below is a variables that stores received data
  	success: function (data){
     	// Suppose you have an html element, where you want to append 
     	// the response:
     	$('#<Your html element id>').html(data);
  		// .html(data) overwrites existing data
		// Use .append(data) to add response without overwriting!
  	}
});

V jiných jazycích

Tato stránka je v jiných jazycích

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................