You're right. It could be two functions. Making it one was simply a design choice. If you were to have lots of different actions on a page resulting in an xmlhttprequest call, it can be a lot tidier just to have a single function to handle each action.
If using two functions works better for you, there's no reason not to do it that way.