Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class fiche_content{
- private $file_base;
- private $jenkins_url;
- function __construct($jenkins_token){
- $this->file_base = plugin_dir_path( dirname( __FILE__ ) ) . 'fiche.php';
- $this->jenkins_url = $jenkins_url;
- $this->init();
- }
- function init() {
- add_action('wp_head', array( $this, 'js_scripts' ));
- add_action('wp_ajax_action_function', array( $this, 'action_function' ));
- }
- function js_scripts(){
- $script = "
- <script type='text/javascript'>
- jQuery(document).ready(function($) {
- $(document).on('click', '#launchBuildForm',function(e){
- var url =" . $this->jenkins_url . ";
- $.ajax({
- method:'post',
- url: url,
- crossDomain: true,
- dataType: 'jsonp',
- data: {
- 'action': 'action_function'
- },
- success: function (msg) {
- console.log(msg);
- console.log('success');
- },
- error: function(jqXHR, textStatus, errorThrown){
- console.log(jqXHR, textStatus, errorThrown);
- }
- });
- });
- });
- </script>
- ";
- echo $script;
- }
- function action_function(){
- echo 'test';
- wp_die();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement