Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var httpRequester = (function () { //success error -> callbacks
- function getJson(url, success, error) {
- $.ajax({
- url: url,
- type: "GET",
- contentType: "application/json",
- timeout: 5000,
- success: success,
- error : error
- })
- }
- function postJson(url, data, success, error) {
- $.ajax({
- url: url,
- type: "POST",
- contentType: "application/json",
- timeout: 5000,
- data: JSON.stringify(data),
- success: success,
- error: error
- })
- }
- return {
- getJson: getJson,
- postJson: postJson
- }
- }());
- var user =
- {
- "username": "Dodo",
- "authCode": "6fa9133efe05348e430bd5a4585b595f0cb6cba3"
- }
- httpRequester.postJson("http://localhost:40643/api/user/login", user, function () { alert("success") }, function () { alert("error") });
Advertisement
Add Comment
Please, Sign In to add comment