Jquery function to serialize an into an object