mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-17 00:35:55 +01:00
1ef246a589
- TWebContext param in the actions is optional - In case of "action not found", the server dont returns NEVER the document index - Refactoring - More unit tests - BasicDemo updated with typed actions - Copyright updated (just formatting)
55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
function sendData() {
|
|
$.ajax({
|
|
url: '/hello',
|
|
type: 'POST',
|
|
contentType: 'application/json',
|
|
data: JSON.stringify({name: "Bob"}),
|
|
processData: false,
|
|
dataType: 'json'
|
|
}).success(function(data) {
|
|
content.html(JSON.stringify(data));
|
|
}).fail(function() {
|
|
console.log(arguments)
|
|
});
|
|
}
|
|
|
|
|
|
var content = null;
|
|
var btn1, btn2;
|
|
$(document).ready(function() {
|
|
content = $('#content');
|
|
$('#btn1').click(function() {
|
|
console.log("Button1 Clicked");
|
|
$.get("/hello")
|
|
.success(function(data) { content.html(data);})
|
|
.fail(function(){console.log(arguments)});
|
|
});
|
|
|
|
$('#btn2').click(function() {
|
|
console.log("Button2 Clicked");
|
|
sendData();
|
|
});
|
|
|
|
$('#btn3').click(function() {
|
|
console.log("Button3 Clicked");
|
|
$.get('/div/20/2')
|
|
.success(function(data) {
|
|
content.html("20 / 2 = " + data.result);
|
|
})
|
|
.fail(function() {console.log(arguments)});
|
|
});
|
|
|
|
$('#btn5').click(function() {
|
|
alert('This will raise an exception');
|
|
console.log("Button5 Clicked... this will raise an exception");
|
|
$.get('/div/20/0')
|
|
.success(function(data) { /*never called in this demo*/})
|
|
.fail(function(obj, err, message) {
|
|
var html = "<h1>Error raised!</h1>";
|
|
html+='<p>HTTP Status code: ' + obj.status + '</p>';
|
|
html+='<p>Response Text: ' + message + '</p>';
|
|
content.html(html);
|
|
console.log(arguments)
|
|
});
|
|
});
|
|
}); |