Create: PUT /api/0.6/node/create = Problem to get the nodeId

Hello community,
I develop a POI editor but I have a problem to get the nodeId. I already got the changesetId.
The XMLHttpRequest is successful but I get an error in the response message where I normally have the nodeId.

The error message is: “. Fatal error: Extra content at the end of the document at :2.”

It is not the whole code but I think the relevant code.


function createNewOsmNode(action){

    //XML
    var xmlOSM = "<\?xml version='1.0' encoding='UTF-8'\?>\n"
    xmlOSM += "<osm version=\"0.6\" generator=\"OpenStreetMap server\"> \n";
    xmlOSM += "<node id=\"" + nodeId + "\" changeset=\"" + changeSetId + "\" version=\"" + version + "\" lat=\"" + lat + "\" lon=\"" + lon + "\">\n";
    xmlOSM += xmlNode;
    xmlOSM += "</node>\n</osm>";
    // Sending content
    osmNode(action, xmlOSM);
}

function osmNode(action, data){

    var url =  host + "api/node.php";

    var params = new Object();
    params["action"] = action;
    params["changeset_id"] = changeSetId;
    params["node_id"] = nodeId;
    params["comment"] = commentId;
    params["userName"] = userName;
    params["userPassword"] = pwd;
    params["data"] = data;

    document.getElementById("saving").style.visibility = "visible";

    new Ajax.Request(url, {

        method: 'get',
        parameters: params,
        onSuccess: function(transport){
            var response = transport.responseText;
            switch (action){
                case "create":
                    nodeId = trim(response);   //here I got the error message and not the id.
                case "move":
                case "update":
                case "delete":
                    // updateOSM();
                    break;
            }
            document.getElementById("saving").style.visibility = "collapse";
            return "0";
        },
        onFailure: function(){
            document.getElementById("saving").style.visibility = "collapse";
            alert("crap");
            return "-1";
        },
        onException: function(request, exception){
            document.getElementById("saving").style.visibility = "collapse";
            alert("crap" + exception + request);
            return "-1";
        }
    });
}

Any ideas ?

greet Christian

What is the host?

And should not it be: var url = host + “node/create”;

To create a node the Put method has to be used as far as I know.

Well… just at first glance… i do not use Ajax myself…

Thx for the answer.

Host is the base URL from my server and I am using the PUT method in the php file. There I send the parameters, the PUT method and the path (/api/0.6/node/create).
With the Ajax Request I want to get the nodeId as I did successfully with the changesetid.

No idea ?

Your comments to my reply were so minimalistic that I thought that you were not really interested in a solution.

You did not tell the actual url you used.

As I understand you use an Ajax request. This requests invokes the call of a php page. What the
php page produces would be a nodeid if all went ok?

So why not concentrate on the php page itself? There the put method is used. The result of the put method
should be the id? Then what was the (error)result in the php page itself?