Skip to content

Commit

Permalink
add search request
Browse files Browse the repository at this point in the history
  • Loading branch information
peterorlowsky committed Apr 25, 2018
1 parent 77e5c85 commit 018f550
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<meta charset="utf-8">
<div id="ms-wrapper"></div>
<button disabled onclick="alert(selectedId)">show Table</button>
<button disabled onclick="showTable()">show Table</button>
<div id="stock-table"></div>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mootools/1.6.0/mootools-core.min.js"></script>
<link rel="stylesheet" href="styles.css">
Expand Down
20 changes: 20 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,26 @@ function createIcon(type) {
alt: 'icon'
})
}

/**
* Makes a get request and
*/
function showTable() {
const table = $('stock-table');
new Request({
url: 'example.php',
method: 'get',
onRequest: function(){
table.set('text', 'loading...');
},
onSuccess: function(responseText){
table.set('text', responseText);
},
onFailure: function(){
table.set('text', 'Sorry, your search ' + selectedId + ' could not be loaded.');
}
}).send('param=' + selectedId);
}
// function loadJSON(callback) {
// var xobj = new XMLHttpRequest();
// xobj.overrideMimeType("application/json");
Expand Down

0 comments on commit 018f550

Please sign in to comment.