JSON File:
{
"contactNumber":"12123123",
"emailId":"info@sltscrs.com"
}
JQuery Code: it reads the file
$.getJSON('js/file.json', function (sc) {
$('#phoneNumber').html('<span>'+sc.contactNumber+'</span>');
$('#emailId').html('<span>'+sc.emailId+'</span>');
});
HTML Page: Displays the value
<div class="spann2t">
<ul class="logo-head2">
<li><h2 id="contactNumber"></h2></li>
<li><p id="emailId"></p></li>
</ul>
</div>
email id works. It shows the value. contactNumber does not show any value.
Aucun commentaire:
Enregistrer un commentaire