jquery - Make ajax call ,success and error as functions -
i want make ajax calls , retrieve responses via functions parameters, getting triggered error function , don't know why. here code:
ajaxinavdenormal = function(url_link, successfunction, errorfunction) { $.ajax({ url: url_link, success: function(response) { var respo = response; successfunction(respo); }, error: errorfunction, }); }; ajaxinvadeerror = function() { $('.div1').prepend('internet connection error'); }; isitactivepopup = function(response) { if (response == "success") { $('.div1').prepend('connection successs'); } else $('.div1').prepend('connection error'); }; isitactive = function(data) { var url_link = "http://someurl.com/somegetvar=" + data; ajaxinavdenormal(url_link, isitactivepopup, ajaxinvadeerror); }; globalactions = function() { isitactive(); }; $(document).ready( function() { globalactions(); });
<!doctype html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> </head> <body> <div class="div1"></div> </body> </html>
as wrote above, trying pass data via method:
isitactive = function(data)
however, didn't include when calling @
globalactions = function() { isitactive();};
as result, there no data process.
Comments
Post a Comment