Trying to update two fields of a shapefile using a WFS update service published from GeoServer 2.4.3 with OpenLayers 2.13.1. I have a JavaScript with all the OpenLayers fun and a HTML document with all the interface fun. Essentially the user clicks on an object and updates a form and then saves it.
Assuming its possible? It's probably really simple but I can't crack it. The fields do not update and in the demo requests the service times out.
Here is the code I am trying;
function saveHandler() {
newDim = document.getElementById("dimension").value;
var num = parseFloat(newDim);
var newDimRound = num.toFixed(3);
newMaterial = document.getElementById("MaterialDD").value;
var saveDetails = OpenLayers.Request.POST({
url: '',
username: '',
password: '',
data: ' 'xmlns:topp="http://www.openplans.org/topp"\n' +
'xmlns:ogc="http://www.opengis.net/ogc"\n' +
'xmlns:wfs="http://www.opengis.net/wfs">\n' +
'\n' +
'\n' +
'Field 1 \n' +
'' + newDimRound + ' \n' +
'Field 2 \n' +
'' + newMaterial + ' \n' +
' \n' +
'\n' +
'Spatial_ID \n' +
'' + getSpatial_ID + ' \n' +
' \n' +
' \n' +
'\n',
callback: handler
}); // end of Post
function handler(updateSQL) {
alert("Details Saved!")
} // end handler
};
I have tried putting the fields in their own property sections and different orders to no avail.
Answer
Worked it out, feel like a dunce! I needed to separate each property into it's own distinct property within the xml, rather than combine it into one.
I had:
Needed to have:
Like so:
data: ' 'xmlns:topp="http://www.openplans.org/topp"\n' +
'xmlns:ogc="http://www.opengis.net/ogc"\n' +
'xmlns:wfs="http://www.opengis.net/wfs">\n' +
'\n' +
'\n' +
'Field 1 \n' +
'' + newDimRound + ' \n' +
' \n' +
'\n' +
'Field 2 \n' +
'' + newMaterial + ' \n' +
' \n' +
'\n' +
'Field 3 \n' +
'' + remarks + ' \n' +
' \n' +
'\n' +
'Spatial_ID \n' +
'' + getSpatial_ID + ' \n' +
' \n' +
' \n' +
'\n',
No comments:
Post a Comment