So far I've succeeded to get my BSP MVC model working.
Here is my code.
View
<body>
<z:form>
<z:input binding="//c/counter"
invisible="true"/>
Counter : <z:write binding="//c/counter"/>
<z:button fcode="incr"
text="Increase"/>
<z:button fcode="decr"
text="decrease"/>
</z:form>
</body>
Controller
Through fcode I invoke the "fcode_incr" method in Controller.
'c' is a model instance of zcl_counter.
it has an attribute counter which will be increased by this method.
method fcode_incr.
c->increment( ).
endmethod.
I hope zcl_model is obvious and its code is not relevant here.
The problem when I press the "increase" button, server sends a request. When it gets the response, it refresh the page. So i get the incremented value. how can I get it working with Ajax so the page remains without refreshing?
I've already tried Ajax with "XML page with flowlogic". like "Eventhandler-->OnRequest"
request->get_form_field('variable').
Does it help any further?
The correct Ajax Call would be
$.ajax({
url:'ajaxController.do',
statusCode:{
404: function(){
alert("not found");
}
},
success: function(data){
$('#viewData').html(data);
}
}).error(function(){
alert("failed");
});