I'm porting working PHP application to Java/Wicket. I have a lot of complex, well written jQuery/javaScript which I would like to reuse and not change too much. Obviously I have to change urls in ajax calls and rewrite the server side scripts from PHP to Java. I tought this task would be simple but somehow I can't figure out how to write server side that would respond to ajax call. Simple example: javascript:
function f(){
jQuery.ajax({
data: 'object_type=1&object_id=2',
url: 'ajax/get_object.php',
timeout: 2000,
type: 'POST',
dataType: 'json',
success: function(r) {
alert(r);
}
});
}
Php file ajax/get_object.php:
// ... create $json_string here
echo $json_string;
I have found AbstractDefaultAjaxBehavior which I probably should use to implement server side of such ajax call, but I'm not really sure how to use it. I'm not really Java kind of guy so try to explain step by step what sould I do :-)