What is "mi'Yam la'Ai"?
Rashi: It is west of Ai; Beis Kel is to the west.
Why did Yehoshua spend the night amidst the people?
Rashi: It was to be ready early in the morning.
Radak: It was to make them zealous to rise early in the morning and engage in the war.
How much in advance did Yehoshua send the ambush, and why?
Malbim: It was two days. 1 This was so they could go far from the city, through fields and Midbaros, so people of the city would not see them.
Yehoshua spent the night amidst the people, rose in the morning, camped north of Ai, and spent the night in the valley before the battle the next day (verses 10, 11, 13).
QUESTIONS ON RASHI
Rashi writes that "mi'Yam la'Ai" is to the west. The ones who would flee were in front of the city, to the north (verse 11). If so, in back of the city is to the south! Also, the people of Beis Kel came to help Ai. Why did they not encounter the ambush, who were between the cities?
Malbim: The ambush was to the southwest. Anshei Beis Kel went to the east to Ai, and did not notice the ambush, for they were south of them.