better ajax that handle content length for post request