[OpenLayers-Users] Getting server output when using save strategy
Adrian Popa
adrian_gh.popa at romtelecom.ro
Tue Jul 6 08:19:31 EDT 2010
Hello everyone,
I'm trying to create a callback function for the save strategy so that I
can display a status message for the user in case there are problems
with saving their changes (e.g. - session expired, etc).
I want the serverside script to send back a JSON formatted string that
would describe what the problem was - for instance:
({'failure':true,'error':'You do not have rights to make changes'}). I
indend to eval this message and extract the error and show it to the user.
I have created a trigger that fires on "success", but I can't find
anywhere the response from the server (so that I can parse it):
var saveStrategy = new OpenLayers.Strategy.Save();
saveStrategy.events.on({'success': function(event){
alert("On save success");
}});
The event parameter that gets passed to the function has a
"Strategy.Save" object and a "Protocol.Response" object. By browsing
both of them I still couldn't find the original message returned by the
server.
By the way, the server returns content-type text/html.
I noticed that the failure event is triggered when the server returns a
500 error, but I wouldn't want to have to crash my server-side script on
purpose in order to catch a problem on the client-side.
Am I missing something or doing something wrong?
Thanks,
Adrian
More information about the Users
mailing list