Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function callApi(params, callback){
- var xhr = new XMLHttpRequest();
- xhr.onreadystatechange = function(){
- if(this.readyState == 4){
- callback(this.responseText);
- }
- }
- var post = "";
- if(params.post != null){
- for(var key in params.post){
- var val = params.post[key];
- post += "&" + key + "=" + val;
- }
- post = post.substr(1, post.length);
- }
- xhr.open(params.type, '/index.php?option=com_apicart&task=' + params.method);
- xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- xhr.setRequestHeader("Content-length", post.length);
- xhr.setRequestHeader("Connection", "close");
- xhr.send(post);
- }
Add Comment
Please, Sign In to add comment