html - How to store returned string from php file to Javascript variable through Ajax -


i want call php function ajax , have contents returned webpage.

say have file called latest.php returns simple html.

$result = "<div> text </div>"; echo $result; 

how can write ajax script calls php file, returns html , stores in javascript variable?

javascript variable:

var myvar; $.get("latest.php", function(data) {     myvar = data; }); 

insert document:

$.get("latest.php", function(data) {     $("#myelement").html(data); }); 

or

$("#myelement").load("latest.php"); 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -