Closed hikari-no-yume closed 9 years ago
Would follow the Don't Repeat Yourself principle. Could also make for a nicer API, something like this:
postRequest(SID, { action: 'foobar', ... }, function (result) { // success! ... }, function (error) { // failure! ... });
No need to specify the URL, everything goes to /api.php after all.
/api.php
You could have a similar function for GET requests as for POST requests, it'd just URL encode the parameters rather than sending them as a JSON body.
Done by https://github.com/TazeTSchnitzel/PictoSwap/commit/dc5cbb54e96da8a9ce5938290e3be6ba6b0e771d
Would follow the Don't Repeat Yourself principle. Could also make for a nicer API, something like this:
No need to specify the URL, everything goes to
/api.php
after all.You could have a similar function for GET requests as for POST requests, it'd just URL encode the parameters rather than sending them as a JSON body.