Seach

Showing posts with label ajax. Show all posts
Showing posts with label ajax. Show all posts

How to load json data into a page using jquery and ajax

jason.php

<script type="text/javascript" src="../jquery/jquery-1.11.1.min.js"></script>
<script>
$(document).ready(function(e) {
    $.ajax(
    {
        url:"country.json",dataType:"json",success: function(response)
    {
        $("#result").html("First name="+response.first_name);
        $("#result2").html("Last Name="+response.last_name);
    }
    });
});
</script>
<div id="result"></div>
<div id="result2"></div>

country.json

{
"first_name":"Hithin ",
"last_name":"Chandran",
"third":"3.yyy"
}

how to display a textfile data using jquery ajax techniqe

<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<div id="txt">
</div>
<input type="button" id="Load" value="Load">
<script>
$(document).ready(function(e) {
    $("#Load").click(function(e) {
        $.ajax(
        {
            url:"text.txt",
            success: function(result)
        {
            $("#txt").text(result);
        },error: function(result)
        {
        }
        });
    });
});
</script>

how to display file content using ajax php

function select_browser()
{
    //alert("executed");

    var xmlhttp;
    if(window.XMLHttpRequest)
    {
        //alert("browser is internet firefox");
        xmlhttp=new XMLHttpRequest();
        return xmlhttp;
    }
    else
    {
       
        xmlhttp=new ActiveXobject("MICROSOFT.XMLHTTP");
        return xmlhttp;
    }

}

function load_file()
{
   
   
    ajax.onreadystatechange = function()
    {
        if(ajax.readyState == 4 )
        {
            document.getElementById('message').innerHTML=ajax.responseText;
        }
    }
    ajax.open("POST","file.txt");
    ajax.send();
   
}