Use Ajax to call php function with paremeters -


first off - no jquery. hate thing passion , can't possibly imagine how native code implementation less efficient.

what after way call php function javascript , pass parameters function using call_user_func_array. have written exact code before can't think of how did it.

in end, want able (in js) able like:

var responsestring = callphpfunction(func, param1, param2, etc); 

`

which ideal , involve few nested functions. @ moment have basic ajax request. needs post, , doesn't have handle multiple requests simultaneously.

var lastresponse = '';  function phpfunction(funcname){ var ajaxrequest;   try{     // opera 8.0+, firefox, safari     ajaxrequest = new xmlhttprequest(); } catch (e){     // internet explorer browsers     try{         ajaxrequest = new activexobject('msxml2.xmlhttp');     } catch (e) {         try{             ajaxrequest = new activexobject('microsoft.xmlhttp');         } catch (e){             // went wrong             alert('ajax/browser problem!');             return false;         }     } } // create function receive data sent server ajaxrequest.onreadystatechange = function(){     if(ajaxrequest.readystate == 4){                      //seems work.         window.lastresponse = ajaxrequest.responsetext;     } } ajaxrequest.open('post', 'ajaxcall.php', true); ajaxrequest.send('func='+funcname); //need generate parameters dynamically, not sure how } 

this shouldn't complex, i've never seen implementation of it.

any ideas?


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -