Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how draw table from json ajax

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>WCF Client</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

</head>

<body>

<table id="location" border='1'>
    <tr>
        <th>Countries</th>
         <th>Cities</th>
    </tr>
</table>

<script>

var service = 'http://localhost/DistributedDataSystem/Service.svc/';

$(document).ready(function(){

    jQuery.support.cors = true;

    $.ajax(
    {
        type: "GET",
        url: service + '/GetAllCountries/',
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        cache: false,
        success: function (data) {

        var trHTML = '';

        $.each(data.Countries, function (i, item) {

            trHTML += '<tr><td>' + data.Countries[i] + '</td><td>' + data.Cities[i] + '</td></tr>';
        });

        $('#location').append(trHTML);

        },

        error: function (msg) {

            alert(msg.responseText);
        }
    });
})

</script>

</body>
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: nextjs framer motion 
Javascript :: javascript round .5 down 
Javascript :: javascript add dom disabled 
Javascript :: paragraph antd 
Javascript :: lodash clone 
Javascript :: curl send json as variable 
Javascript :: jquery carousel slide event 
Javascript :: array destructuring in react 
Javascript :: discord.js get server guild id 
Javascript :: merge objects javascript es6 
Javascript :: javascript integer 
Javascript :: import tippy react 
Javascript :: how to know the current route in react class component 
Javascript :: vue dynamic routes with parameters 
Javascript :: react comments 
Javascript :: map a square to a circle 
Javascript :: download pdf javascript 
Javascript :: regex negate 
Javascript :: ajax get request parameters 
Javascript :: how to use mongoose-encryption 
Javascript :: js array elements sum 
Javascript :: svg css viewbox 
Javascript :: how to select a few properties from an object javascript 
Javascript :: discord js embeded message hyperlink 
Javascript :: javascript array push 
Javascript :: delay javascript 
Javascript :: get all parent nodes of child in javascript array 
Javascript :: angular cli no test 
Javascript :: merg two array js 
Javascript :: arrow functions in javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =