Fix jquery throwing exceptions on wrong query syntax