Hi Nader,
That bit of code is checking the origin of the service URL. You are probably hitting the CORS issue - this is documented in the SAPUI5 here: https://sapui5.netweaver.ondemand.com/sdk/#docs/guide/SecurityGuide.html
If the origin of your SAPUI5 app and the origin of the Service you are calling is different it tries to use the built in proxy. Is your app and the service coming from the same source/origin?
Hth,
Simon