“in front of the city.” The point of Joshua and his troops was to be seen, so they marched in front of the city. Then they camped to the north of the city, which may or may not have been in front of the city. There are a couple of geographical locations that are possible ruins of the city of Ai. The main one is Et-tell, but the other possibility is Kirbet Maqatir.
“there was a ravine between him and Ai.” That is, between Joshua and Ai. If the archaeologists and historians are correct that the biblical city of Ai is et-Tell today, then this ravine is today called the Wadi Jaya.