Can any of your dojo experts out there tell me why I am getting an error “unable to load: [url]” when running this script? Any help much appreciated.
var nhsURL = “http://www.nhs.uk/NHSCWS/Services/ServicesSearch.aspx?”;
alert(nhsURL);
var xhrArgs = {
url: nhsURL,
content: {
user: "xxx",
pwd: "xxx",
q: "ss155rs",
type: "1"
},
load: function(response, ioArgs) {
dojo.byId("name").innerHTML = response;
alert(response);
},
error: function(response, ioArgs) {
console.error("HTTP status code: ", ioArgs.xhr.status);
alert(response);
}
}
var ress = dojo.xhrGet(xhrArgs);
alert(‘done’);
Subject: If I load the link manually I get nothing…
-
No without content, nothing. View source is utterly blank. Try using a page that gives something back.
-
Also use FireFox & FireBug. That will show you the AJAX request and response so you may directly see what’s going on. Lastly try a packet capture to see what’s on the wire … I’ve seen AJAX fail because it can’t understand the return, and neither can FireBug so it doesn’t show it correctly. Packet capture never lies.
Hope this helps…
Subject: blank
Thanks david, you do need to pass in the correct username and password parameters to return anything. I do use firebug, so prob need to familiarise myself with sort of the features you described.
Thanks again.
Subject: Slight change - still broken…
fyi: I have replaced alert(response);
with
alert(‘success’);
alert(‘failure’);
respectively, but still doesn’t work.
Subject: Is you domino server in the same domain ?
As far as I know, it’s not allowed to do an ajax call on a different domain than yours. Not only in dojo, but in javascript in all browsers.
As your ajax call try to connect to http://www.nhs.uk, is www.nhs.uk your server ?
Does your server is at least named xyz.nhs.uk ?
If not, than your browser refuses for security reason to retrieve datas from another domain.
With dojo, there is maybe a workaround, but I don’t know enough Dojo to help this far, but I have seen some articles on google if you search for :
dojo ajax different domain
Hope this helps a bit at least… 
Renaud
Subject: Domain
Hi Renauld,
It’s not in the same domain at all. So this will be the problem. The data is publically available, would you recommend using a web service instead?
Thanks again.
Subject: Try to do kind of a proxy request
James,
What you can do, is a notes agent which will get the datas server side from www.nhs.uk website and return the datas you want.
Then you can you an ajax request on this agent with appropriate parameters if needed.
This way your ajax request stays in the same domain (it’s your server) and the agent get the datas server side and returns it the the ajax request. Then you’ll be able to handle the result and do whatever you need.
The only thing you need to be sure is that your domino server is not blocked by a firewall when he gets the datas from the website. You’ll probably have to raise the runtime security level of your agent (second tab of the agent properties).
But also think that maybe if you run this agent maybe you won’t need the ajax request. If it’s done at the open time of a document, you can run this agent in the webqueryopen of this document. It depends on what you’re trying to achieve.
The good thing of this “proxy” solution is that the user and password won’t be visible to the user. In the ajax request you tried to do, they would.
I hope my explanation is not too foggy… 
Renaud