forked from jport/FrontHouse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createStore.js
40 lines (35 loc) · 1.29 KB
/
createStore.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
$(document).ready(function() {
//get all html elements by their id
var name = $('#StoreName');
var number = $('#StoreNumber');
var address = $('#StoreAddr');
var state = $('#State');
var city = $('#City');
var zip = $('#Zip');
//on click execute the stores signup
$('#SignUp').on('click', function () {
//make the payload to send to the database
var payLoad = {
StoreName: name.val(),
StoreNumber: number.val(),
Address: address.val(),
State: state.val(),
City: city.val(),
Zip : zip.val(),
};
var payLoadString = JSON.stringify(payLoad);
//send the json payload using ajax
$.ajax({
type: 'POST',
url: 'http://knightfinder.com/WEBAPI/CreateStore.aspx',
data: payLoadString,
success: function(newStore) {
localStorage.setItem("StoreID", newStore.StoreID);
location.href="makeManager.html";
},
error: function() {
alert("error contacting the api \n error code: "+ error);
}
});
});
});