<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 = document.createElement("a");
a.download = "Customers.txt";
a.href = link;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
}
</script>