Created
March 13, 2010 16:11
-
-
Save furf/331399 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Only instantiate once and append the calls in your loop | |
// Because XHR responses pop out of the stack, all of the | |
// requests will be linked and sent before the first can | |
// return. | |
// Also, when passing the settings object as a config, | |
// the callback is inside the object. The signatures for | |
// sexy methods are (url, callback) or (settings) | |
// Can configure globally for the Sexy instance | |
// URL may even work up here since it's the same? | |
var sexy = Sexy({ | |
url: "/api", | |
type: "POST" | |
}); | |
for (aTest in tests) { | |
var jsonRPCWrapper = { | |
method: tests[aTest].method, | |
params: [tests[aTest].params.data], | |
id: (new Date()).getTime() | |
}; | |
(function (aTest) { | |
sexy.json({ | |
data: JSON.stringify(jsonRPCWrapper), | |
success: function (rsp) { | |
// create new row in table for each test | |
$('#testResults').append('<tr class = "'+name+'">' + | |
'<td class = "test">'+aTest+'</td><td class = "result">' + | |
JSON.stringify(rsp)+'</td></tr>'); | |
} | |
); | |
})(aTest); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment