Ajax, php: php modularization for front-end ajax call implementation: Background: The php framework is not used. due to temporary requirements, ajax is required to call the methods in php and a php file is simply written, the file defines two methods, and how to use ajax to call different methods of the same PHP file. The following is the abc. php file. I have defined two methods: Method a and Method B. The following is the Co background: php framework is not used.
Due to temporary requirements, ajax is required to call methods in php. a php file is simply written, and the file defines two methods. ajax is used to call different methods in the same php file.
The following is the abc. php file. I have defined two methods: Method a and Method B.
The following is Controller. php. This file is a Controller that calls other specific function classes and plays a pivotal role. it is mainly implemented through reflection.
hasMethod($method_name)) { $func = $class->getmethod($method_name); $instance = $class->newInstance(); $func->invokeArgs($instance, array($_REQUEST)); } } } catch (Exception$exc) { echo$exc->getTraceAsString(); } }?>
When using ajax, use the following method to call method a in abc. php:
$.ajax({ type:"POST", url: 'Controller.php?action=abc/a', dataType: 'json', success: function(data) { } });
If you need to pass parameters, you can write them as follows:
$. Ajax ({type: "POST", url: 'Controller. php ', data: {action = abc/B, parameter 1: 123, parameter 2: 456} dataType: 'json', success: function (data ){}});
'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
'). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script
The above introduces the implementation of php modularization for front-end ajax calls, including ajax and php content, and hopes to help friends who are interested in PHP tutorials.