everyone, Thanks for watching my question, I hope you can help me. is the following ..
I have the following code.
in html
<div id="summary"></div>
In Js I have
function callurl() {
$.ajax({
url: 'https://jsonplaceholder.typicode.com/posts',
type: "GET",
dataType: "json",
success: function (msg) {
JsonpCallback(msg);
},
error: function () {
ErrorFunction();
}
});
}
function JsonpCallback(json) {
document.getElementById('summary').innerHTML = json.title;
}
callurl();
I need to structure the json, in the following way in the html.
With id in each variable. an example would be
<h4>Post ID:<span id="postid"></span></h4>
<h1>Titulo:<span id="titulo"></span></h1>
<h5>Contenido: <span id="contenido"></span></h5>
Someone can help me.
I have some tests on link
UPDATE Thanks to @jorius
I did the update perfectly in link
Now what I'm asking, how can I
If I have json in the following way ..
{
"orders":[
{
"id":12535,
"order_number":12535,
"created_at":"2017-03-26T18:10:00Z",
"updated_at":"2017-03-27T07:25:49Z",
"completed_at":"2017-03-27T07:25:49Z",
"status":"processing",
"currency":"BHD",
"total":"30.00",
"subtotal":"30.00",
"total_line_items_quantity":1,
"total_tax":"0.00",
"total_shipping":"0.00",
"cart_tax":"0.00",
"shipping_tax":"0.00",
"total_discount":"0.00",
"shipping_methods":"",
"payment_details":{
"method_id":"credimax",
"method_title":"Visa \/ Master Card",
"paid":true
}
},
{
"id":33333,
"order_number":33333,
"created_at":"2017-03-26T18:10:00Z",
"updated_at":"2017-03-27T07:25:49Z",
"completed_at":"2017-03-27T07:25:49Z",
"status":"processing",
"currency":"BHD",
"total":"10.00",
"subtotal":"10.00",
"total_line_items_quantity":1,
"total_tax":"0.00",
"total_shipping":"0.00",
"cart_tax":"0.00",
"shipping_tax":"0.00",
"total_discount":"0.00",
"shipping_methods":"",
"payment_details":{
"method_id":"credimax",
"method_title":"Visa \/ Master Card",
"paid":true
}
},
]
}
As I can, show
<h5>Order numero: <span id="order_number"></span></h5>
<h5>Fecha: <span id="created_at"></span></h5>
of all ...