W3.JS एचटीपी अनुरोध


सर्वर से डेटा पढ़ें:

w3.getHttpObject(file.js,function)

इस पृष्ठ पर उदाहरण पिछले पृष्ठ के उदाहरणों के समान हैं, सिवाय इसके कि डेटा एक वेब सर्वर से अनुरोध किया जाता है: customer.js


एक ड्रॉपडाउन भरना

उदाहरण

<select id="id01">
  <option w3-repeat="customers">{{CustomerName}}</option>
</select>

<script>
w3.getHttpObject("customers.js", myFunction);

function myFunction(myObject) {
  w3.displayObject("id01", myObject);
}
</script>

एक सूची भरना

उदाहरण

<ul id="id01">
  <li w3-repeat="customers">{{CustomerName}}</li>
</ul>

<script>
w3.getHttpObject("customers.js", myFunction);

function myFunction(myObject) {
  w3.displayObject("id01", myObject);
}
</script>

एक टेबल भरना

उदाहरण

<table id="id01">
  <tr>
    <th>Customer</th>
    <th>City</th>
    <th>Country</th>
  </tr>
  <tr w3-repeat="customers">
  <td>{{CustomerName}}</td>
  <td>{{City}}</td>
  <td>{{Country}}</td>
  </tr>
</table>

<script>
w3.getHttpObject("customers.js", myFunction);

function myFunction(myObject) {
  w3.displayObject("id01", myObject);
}
</script>

एक और टेबल भरना

उदाहरण

<table id="id01">
  <tr>
    <th>Title</th>
    <th>Artist</th>
    <th>Price</th>
  </tr>
  <tr w3-repeat="cd">
  <td>{{title}}</td>
  <td>{{artist}}</td>
  <td>{{price}}</td>
  </tr>
</table>

<script>
w3.getHttpObject("cd_catalog.js", myFunction);

function myFunction(myObject) { 
  w3.displayObject("id01", myObject);
}
</script>