Posts Tagged ‘javascript’

Since the official wxJavaScript docs advocate using XAMPP for development, that’s what I got and that’s where I installed wxjs. Following the directions was pretty easy, but getting any meaningful output apart from Apache crashing was pretty hard. The error.log gave it away, albeit indirectly, and a quick glance at the wxjs newsgroups proved the [...]


It’s a bit of a head-scratcher at first, seeing as the jQuery docs mysteriously disavow a postJSON possibility, let alone a function, but it’s definitely doable. So here’s the glorious code:
function postjson(url,data,bS,s,e){
$.ajax({type:”POST”,url:url,data:data,dataType:”json”,
beforeSend:bS,success:s,error:e});}
Use it like so:
postjson(“name.php”,”name=Bob”,
function(){$(“#name”).text(“…”);},
function(json){$(“#name”).text(json.name);},
function(){$(“#name”).text(“Error”);});
If name.php’s output looks like this…
{“name”:”Bob”}
…the above should, upon execution, change the ID “name” to contain the text “Bob.” [...]