<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function DownloadJSON() {
//Build a JSON array containing Customer records.
var customers = new Array();
customers.push(["Customer Id", "Name", "Country"]);
customers.push([1, "John Hammond", "United States"]);
customers.push([2, "Mudassar Khan", "India"]);
customers.push([3, "Suzanne Mathews", "France"]);
customers.push([4, "Robert Schidner", "Russia"]);
//Convert JSON Array to string.
var json = JSON.stringify(customers);
//Convert JSON string to BLOB.
json = [json];
var blob1 = new Blob(json, { type: "text/plain;charset=utf-8" });
//Check the Browser.
var isIE = false || !!document.documentMode;
if (isIE) {
window.navigator.msSaveBlob(blob1, "Customers.txt");
} else {
var url = window.URL || window.webkitURL;
link = url.createObjectURL(blob1);
var a = $("<a />");
a.attr("download", "Customers.txt");
a.attr("href", link);
$("body").append(a);
a[0].click();
$("body").remove(a);
}
}
</script>