Unobtrusive scripting is fun!
-
I recently went to QCon, and one of the many excellent talks there was about how we should be writing web applications. Among many other things, he said that we should use unobtrusive scripting (i.e. make the page usable even if it's turned off, and then enhance things live). So I'm trying to do that with the cricket club website I've taken over. And you know, it's actually kind of fun writing JavaScript to muck about with the DOM to do UI-enhancing things :^) (So far I have: <a> tags can get enhanced to be AJAX grabs, instead of a page jump; <form>s can be enhanced to do an AJAX POST; and <div>s can be enhanced to be hidden but provide a show/hide link, for the kind of threaded comments page like what they do here.)
-
I recently went to QCon, and one of the many excellent talks there was about how we should be writing web applications. Among many other things, he said that we should use unobtrusive scripting (i.e. make the page usable even if it's turned off, and then enhance things live). So I'm trying to do that with the cricket club website I've taken over. And you know, it's actually kind of fun writing JavaScript to muck about with the DOM to do UI-enhancing things :^) (So far I have: <a> tags can get enhanced to be AJAX grabs, instead of a page jump; <form>s can be enhanced to do an AJAX POST; and <div>s can be enhanced to be hidden but provide a show/hide link, for the kind of threaded comments page like what they do here.)
-
I'm aware of jQuery, thanks (is there anyone who does web stuff that isn't?). I actually had to use some pieces of it for Real Work at the back end of 2011 (its date/time picker). I'm having fun working things out myself, though. I don't really like using frameworks if I don't have to, and since this is not really work, I don't have to. (Yet :P.)
-
I recently went to QCon, and one of the many excellent talks there was about how we should be writing web applications. Among many other things, he said that we should use unobtrusive scripting (i.e. make the page usable even if it's turned off, and then enhance things live). So I'm trying to do that with the cricket club website I've taken over. And you know, it's actually kind of fun writing JavaScript to muck about with the DOM to do UI-enhancing things :^) (So far I have: <a> tags can get enhanced to be AJAX grabs, instead of a page jump; <form>s can be enhanced to do an AJAX POST; and <div>s can be enhanced to be hidden but provide a show/hide link, for the kind of threaded comments page like what they do here.)
BobJanova wrote:
<form>s can be enhanced to do an AJAX POST
I am currently busy with trying to find a mechanism to make a non-form, i.e. a sub-form (not allowed, but is a group of inputs and a URL) post via AJAX.
-
BobJanova wrote:
<form>s can be enhanced to do an AJAX POST
I am currently busy with trying to find a mechanism to make a non-form, i.e. a sub-form (not allowed, but is a group of inputs and a URL) post via AJAX.
Brady Kelly wrote:
I am currently busy with trying to find a mechanism to make a non-form, i.e. a sub-form (not allowed, but is a group of inputs and a URL) post via AJAX.
You could just create a JSON and pass it to the server in the "data" field of a jQuery.ajax request. If you are using C# with Webservices you could do this: (Using jQuery)
$.ajax({
url: "your.url.here/Method",
type: "POST",
data: {json:{a:10,b:20}},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var response = $.parseJSON(data.d);}
});
wich in server will be
public string Method(object json){
//do your stuff here
}or
$.ajax({
url: "your.url.here/Method",
type: "POST",
data: {a:10,b:20},
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
var response = $.parseJSON(data.d);}
});
and server-side
public string Method(int a, int b){
//do your stuff here
}Sorry, my english is bad!