Zef,
I'm using a site that has a JSONP API, but rather than using &callback=? (the default jQuery jsonp parameter) it uses &JSONP=?.
jQuery supports this - you add in jsonp="JSONP" in the parameters to the $.ajax call, but there appears to be no way to insert this parameter in the mobl service definition. Result is that I'm editing the generated javascript.
I guess I could do a messy override of $.ajax to avoid this, but I'm wondering if there's a better way?
--
Mike Pearson
Millennium Mathematics Project,
Centre for Mathematical Sciences,
University of Cambridge
Cambridge CB3 0WA
<javascript>
__ns.fetchSomething = function(..., callback) {
$.ajax({
url: "...",
jsonp: "JSONP",
success: callback
});
};
</javascript>
external function fetchSomething(...) // note: no callback
and then you can just call fetchSomething with your arguments
HTH,
Zef
--
Zef Hemel
http://zef.me
http://twitter.com/zef
service Tesco {
resource login(email:String, password:String, developerKey:String, apiKey:String) : TescoLogin {
uri = "http://www.techfortesco.com/groceryapi_b1/restservice.aspx?command=LOGIN&email=" + email + "&password=" + password + "&developerkey=" + developerKey + "&applicationkey=" + apiKey
encoding = "jsonp"
mapper = TescoLoginMapper
}
var result = TescoLoginMapper(httpRequest("http://www.techfortesco.com/groceryapi_b1/restservice.aspx?command=LOGIN&email="
+ email + "&password=" + password + "&developerkey=" + developerKey +
"&applicationkey=" + apiKey, encoding="jsonp"));
thus, service definitions do not add all that much over a simple
httpRequest (http://docs.mobl-lang.org/mobl). So to replace it with a
native function call also doesn't matter that much.
Zef
Mike
Zef
--