Hi,
Im testing the json rpc server using POST ajax calls.
I've got this in my view:
<script type="text/javascript" charset="utf-8">
$(function(){
$("select#location").change(function(){
$.ajax({url: "/crafty/rpc",
type: "POST",
contentType: "application/json",
data: JSON.stringify({"method":"build_aircraft_list", "params":["1"],
"id":1}),
dataType: "json",
success: function(response) {
alert(response.result);
},
});
})
})
</script>
The alert prints "null", but Im definetely getting a response from the
JSON-RPC server (Google Chrome debugger says so)
HTTP/1.0 200 Ok
Server: CppCMS-Embedded/1.0.0
Connection: close
Content-Type: application/json; charset=us-ascii
X-Powered-By: CppCMS/1.0.0
Now the problem is the build_aircraft_list(int) never gets called . Here
is the JSON_Service class -
JSON_Service::JSON_Service(cppcms::service& srv): json_rpc_server(srv)
{
using namespace cppcms::rpc;
bind("build_aircraft_list",
json_method(&JSON_Service::build_aircraft_list, this), method_role);
}
void JSON_Service::build_aircraft_list(int location)
{
std::cout << "Yay" << std::endl;
return_result("test return");
}
Nothing ever gets printed to cout. So Im assuming the build_aircraft_list
function never gets called.
The RPC server is setup as a SubApplication and CSRF is enabled.
Any ideas?
Thank you
Petr
|