fixed errors when ajax response does not contain "query" property

apparently the ajax response can sometimes miss "data.query", this fixes errors reported when that happens.
i also fixed some indentation.