Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php js

function pp_check_reactapp_ajax() {

    $request = new WP_REST_Request( 'POST', '/wp/v2/posts' );
    $request->set_header( 'content-type', 'application/json' );
    $request->set_body( '{
            "title": "'. $_POST['title'] .'"
        }');

    $response = rest_do_request( $request );

    $server = rest_get_server();
    $data = $server->response_to_data( $response, false );

    if($data['id']){
        echo '{"success": '. json_encode($data) .'}';
    } else {
        echo '{"error": "'. $data['message'] .'"}';
    }

    wp_die();

}
add_action( 'wp_ajax_nopriv_pp_check_reactapp_ajax', 'pp_check_reactapp_ajax' );
add_action( 'wp_ajax_pp_check_reactapp_ajax', 'pp_check_reactapp_ajax' );
Comment

PREVIOUS NEXT
Code Example
Php :: php server on local machine 
Php :: enhanced ecommerce data layer for woocommerce 
Php :: how to get the top_area in orders laravel 
Php :: clear laravel cache and clear vue 
Php :: wordpress custom post type url not working 
Php :: php domdocument get elements one by one 
Php :: php limit results by 30 days 
Php :: $n = readline(); for($i = 0; $i < $n ; $i++) { $name = readline(); $names[$name] = (isset($names[$name]) ? $names[$name] + 1 : 1); } 
Php :: remove public in laravel 
Php :: an einem string etwas anfügen php 
Php :: bring up the power shell console php 
Php :: get_user_info 
Php :: wp+ theme translate 
Php :: add attribute to model laravel 
Php :: nested relation 
Php :: Call to undefined method AppModelsespece::links() laravel 8 
Php :: how to prevent iframe for your site by PHP 
Php :: php mysqli connect to two databases pdo 
Php :: Natural numbers from php 
Php :: view codeigniter 4 
Php :: laravel save or post 
Php :: load more data on button click in laravel 
Php :: php count second different 
Php :: woocommerce php customer reset password length 
Php :: laravel attribute event 
Php :: woocommerce create client account without email 
Php :: curl multi exec get index 
Php :: php doesnt load updates in css 
Php :: laravel mix build as umd 
Php :: To Search Specific Post Type 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =