mercredi 15 juin 2016

Unable load data from local json file present in solution of visual studio 2012

<!DOCTYPE html>
<html>

  <head>
    <script data-require="jquery@*" data-semver="3.0.0" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js"></script>
    <link rel="stylesheet" href="style.css" />
    <script type="text/JavaScript">
         $select = $('#people');
         //request the JSON data and parse into the select element
         $.ajax({
             type:'GET',
             url: 'simple.json',
             dataType:'JSON',
             success:function(data){
                 //clear the current content of the select
                 $select.html('');
                 //iterate over the data and append a select option
                 $.each(data.employees, function(key, val){
                     $select.append('<option >' + val.firstName+ '</option>');
                 })
             },
             error:function(){
                 //if there is an error append a 'none available' option
                 $select.html('<option >none available</option>');
             }
         });
         </script>
  </head>

  <body>
    <select id="people"></select>
  </body>

</html>

This is My working plunker,here i am read the data from local json file. https://plnkr.co/edit/Ys2xxOn1oUCeNL3wqcvJ?p=preview

But when iam trying the same task in My visual studio,the data cannot be loaded from local json file present in solution explorer of visual studio 2012.

Aucun commentaire:

Enregistrer un commentaire