Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
here is my code and i want to convert it to native javascripts

here is ajaxHandler function code
JavaScript
ajaxHandler = {
defaultAttributes: {
type: 'GET',
url: 'index.php/request',
datatype: 'json',
data: {},
success: null,
error: function(data) {
errorHandler.showError('An Error occurred while trying to retreive your requested data, Please try again...');
},
timeout: function() {
errorHandler.showError('The request has been timed out, Please check your Internet connection and try again...');
}
},
sendRequest: function(attributes) {
Paper.giffyLoading.style.display = 'block';
// Program.status('Generating Network Request...');
if (!attributes.nopopup) {
if (attributes.loadmsg) {
Controllers.AnimationController.createProgressBarScreen(attributes.loadmsg);
attributes.loadmsg = null;
}
// else
// Interfaces.AdvancePopup.createModalPopupLoadingDiv();
}
$.ajax(attributes);
}


my attempt to change it to native javasctipts

XMLRequestDefaultHandler = function () {
                        var xmlHttp = new XMLHttpRequest();
                        xmlHttp.open('GET', 'index.php/request', true);
                        xmlHttp.onreadystatechange = function () {
                                if (xmlHttp.readyState === 4 || xmlHttp.status === 200) {

                                } else {
                                        errorHandler.showError('An Error occurred while trying to retreive your requested data, Please try again...');


                                }
                                return;
                        };
                        xmlHttp.send(null);

                }
Posted
Updated 18-Oct-15 2:03am
v2
Comments
Sergey Alexandrovich Kryukov 18-Oct-15 1:39am    
Sorry, this is not a question. If you want to write code without using jQuery, just write it. Any problems with that? You are not asking anything. Does it mean that you want someone to write it for you? Better don't hold your breath.
—SA
Muhammad Asif 18-Oct-15 8:04am    
i have updated the question with my attempt. let me know what steps i have to take now to change it
Krunal Rohit 18-Oct-15 11:37am    
What's wrong with the current code ?
Visit this site, this will help you.

http://youmightnotneedjquery.com/
-KR

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900