I am not sure. As the action for both is different. If i add a single function then same if else would be needed in a different place with a addition ajax call. That's why did it like this.