Browse Source

erased the ajax test

pull/1/head
Senta Mandutz 5 years ago
parent
commit
4d9f3d8648
1 changed files with 0 additions and 43 deletions
  1. 0
    43
      public/index.html

+ 0
- 43
public/index.html View File

<router-link to="/bookmark" class="nav-item nav-link"><i class="material-icons">bookmark</i></router-link> <router-link to="/bookmark" class="nav-item nav-link"><i class="material-icons">bookmark</i></router-link>
<router-link to="/profil" class="nav-item nav-link"><i class="material-icons">person</i></router-link> <router-link to="/profil" class="nav-item nav-link"><i class="material-icons">person</i></router-link>
</nav> </nav>

<!--test to put information into db by ajax-->
<div class="container">
<div class="col-sm-4">
<h3>Ajax Test</h3>
<div>
<form id="messageForm">
<div class="form-group">
<label for="id">Id:</label>
<input type="text" class="form-control" id="id" placeholder="Enter Id"/>
</div>
<div class="form-group">
<label for="message">Message:</label>
<input type="text" class="form-control" id="message" placeholder="Enter Message"/>
</div>
<div id="res">
</div>
<button type="submit" class="btn btn-default" @click.prevent=testform>Submit</button>
</form>
</div>
</div>
</div>
</div> </div>


<script> <script>
const router = new VueRouter({ const router = new VueRouter({
routes routes
}); });
var app = new Vue({
router,
el: '#api',
methods: {
testform: function() {
var id=$("#id").val();
var message=$("#message").val();
console.log ("test "+id+" "+message);
$.ajax ({ url: "/api/test/"+id, data: {msg: message}, method: "GET" }) .done (have_result) .fail (have_error);
function have_result (res) {
console.log (res);
$("#res").text (res[0].message);
}
function have_error (err) {
console.log ("error:");
console.log (err);
}
},
},
});

</script> </script>


<!-- CDN_Vue.js minified lib --> <!-- CDN_Vue.js minified lib -->

Loading…
Cancel
Save