Question: ```
function showErrorMessage(formId,jsonMessage,targetId){
    clearErrorMessage(formId)   

    if(jsonMessage.errorMessage){
        $.each(jsonMessage.errorMessage,function(message){
            var errorMessageDOM = $('<span class="errorMessage"></span>');
            errorMessageDOM.message({type:"error", message:message,dismiss: false});
            $('#'+targetId).append(errorMessageDOM);
        })
    }else if(jsonMessage.fieldErrorMessage){
        $.each(jsonMessage.fieldErrorMessage,function(key,value){
            var errorMessageDOM = $('<span class="errorMessage"></span>');
            errorMessageDOM.message({type:"error", message:value,dismiss: false});

            var inputObj = $('#'+formId).find('input[name="'+key+'"],select[name="'+key+'"]');
            if(inputObj.length == 0){
                $('#'+targetId).append(errorMessageDOM);
            }
            inputObj.each(function(){
                if($(this).is("select")){
                    var parentSelector = $(this).parent('.selector');
                    if(parentSelector.length > 0){
                        errorMessageDOM.insertAfter(parentSelector);
                        return;
                    }
                }
                errorMessageDOM.appendTo($(this).parent());
            });
        })
    }
}

```

What is meant by the line jsonMessage.errorMessage in this function? I am stuck to understand this?

Answer: 
Can I respectfully suggest not doing this? Instead, make `/players` and `/teams` both top-level resources. Control what team a player is on using a property on the player. Then you can update a player's team by `PUT`ting the player with the new team value.

Alternately, make a new top-level resource that contains all the player-team mappings, say '/team-memberships'. Then you could query `GET /team-memberships?teamId=7` or `GET /team-memberships?playerId=2`. You can post and delete to this resources to add and remove players from teams.

Conceptually, a player is not a sub-resource of a team. A player is an independent resource that's associated with a team. I think either of the above approaches will give you more flexibility and be easier to understand and work with.
What about doing something like `POST /teams/1/players/5/transfers`. This would have the effect of creating a "Team Player Transfer". The `id` of the `Team` and the `Player` are provided in the url, and the body can be something like `{ new_team_id: 2 }`. The server can then perform the "transfer" however it likes.

The "Transfer" may or may not be an object in the database (in my situation it is not). This structure seems RESTful to me and it also reads intuitively.