How to create WordPress Ajax More post on Archive.php Page?

I want to Create Ajax "More Post" Button. Not Pagination .
enter image description here

Material design ajax error messages

The material design specifications define the placement and look of error messages related to invalid input on forms as shown below.

enter image description here

I don’t see a specification for error messages that may occur after the form is submitted. example: a login form could generate an “invalid username or password error.” Any ideas on where such an error message should be placed and what it should look like to adhere to the spec?

browser addons – Any utility to display ajax request/response over the website page without having to visit the network console?

Browser network tab can be used to inspect the request/response of ajax calls to backend servers.

Is there a way to display the same data in a div on the page instead of having to go to the network tab always?

I’m solution for client side solutions as I do not have control over the actual website code.

Note: Question is in reference to any website, I do not have access to modify the server side code that delivers the client side JS.

Image showing the data I’m interested to display directly on the page instead of going to ‘Inspect Element’ -> ‘Network Tab’

Below image just shows the ‘request’ tab, but i’m intereseted to display both request and response for last ajax call made to the backend.

Sample YT browser ajax request

ajax – WordPress JSON return unknown characters fo non English characters

for a project i create an endpoint something like wp-json/HSE/v1/reports which return json file
everything is okey , also Engligh words , but for non English words i have real problem that its bring back something like u0645u0627u0647u0627u0646 u0633u06ccu0631u062cu0627u0646
its confusing me at all .

i also check the wp-json/wp/v2/posts and watch the same problem .English words are fine but non English words are not readable .

what should i do to fix this ?
anyone can help me please ?

php – Crear registro en laravel con modal y Ajax

Estoy intentando crear un modal que registre a una persona con su número de celular, lo quiero hacer con Ajax para que no me recargue la página ya que mas adelante habrá un select que se alimentará en simultáneo con la info de la base de datos.

Esto es lo que tengo:

Ruta

Route::post('turnos/addDeliveryModal', (AppHttpControllersTurnoController::class, 'addDeliveryModal'))->name('turnos.addDeliveryModal');

Controlador

public function addDeliveryModal(Request $request){
    $delivery = New Delivery();

    $delivery->nombDelivery = $request->nombDelivery;
    $delivery->celDelivery = $request->celDelivery;

    $delivery->save();

    return response()->json($delivery);
}

Formulario modal

<form method="POST" id="addDeliveryModal">
                    @csrf                
                    <div class="modal-body">
                        <div class="form-group">
                            <label class="form-control-label">Nombre del Delivery</label>
                            <input type="text" name="nombDelivery" class="form-control form-control-alternative" required>                    
                        </div>
                        <div class="form-group">
                            <label class="form-control-label">Telefono o Celular</label>
                            <input type="text" name="celDelivery" class="form-control form-control-alternative" required>                    
                        </div>
                    </div>            
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-success">Guardar</button>
                        <button type="button" class="btn btn-danger  ml-auto" data-dismiss="modal">Cerrar</button>
                    </div>  
                </form> 

Ajax

$("#addDeliveryModal").submit(function(e){
        e.preventDefault();

        let nombDelivery = $("#nombDelivery").val();
        let celDelivery = $("#celDelivery").val();
        let _token = $("input(name=_token)").val();

        $.ajax({
            url: "{{route('turnos.addDeliveryModal')}}",
            type: "POST",
            data:{
                nombDelivery:nombDelivery,
                celDelivery:celDelivery,
                _token:_token
            },
            success:function(response)
            {
                if(response){
                    console.log("hola");
                }else{
                    console.log("hola2");
                }
            }
        });
    });

Screenshot del Formulario
introducir la descripción de la imagen aquí

Screenshot del error que me bota

introducir la descripción de la imagen aquí

El error claramente me dice que no esta registrada con el metodo POST, cuando si lo esta, ya recargue las rutas y el problema persiste
Espero puedan hecharme una mano.

jquery – 403 error When i send ajax request on WordPress website

i have to create a specifif form ta register data into the database and send a mail without refreshing the page

so i create a script.js file :

    (function ($) {
    $(document).ready(function () {

        jQuery('form(name="form_result")').on('submit', function() {
            var form_data = jQuery(this).serializeArray();
            console.log('hello');
            form_data.push({"name" : "security", "value" : ajax_nonce });
            console.log(form_data);
            // Here is the ajax petition
            jQuery.ajax({
                url : ajax_url,
                type : 'post',
                data : form_data,
                success : function( response ) {
                    // You can craft something here to handle the message return
                    alert(response);
                },
                fail : function( err ) {
                    alert("there was an error: " + err );
                }
            });
            // This return prevents the submit event to refresh the page.
            return false;
        });    
      });
})(jQuery);

in my function.php file i declare has follow :

function javascript_variables(){ ?>
    <script type="text/javascript">
        var ajax_url = '<?php echo admin_url( "admin-ajax.php" ); ?>';
        var ajax_nonce = '<?php echo wp_create_nonce( "secure_nonce_name" ); ?>';
    </script><?php
}
add_action ( 'wp_head', 'javascript_variables' );


//AJAX REQUEST
function twentytwentychild_asset() {
    // ...
    wp_enqueue_script('jquery');

    // Charger notre script
    wp_enqueue_script(
        'twentytwentychild',
        get_stylesheet_directory_uri(). '/assets/js/script.js', 
        array('jquery'),
        '1.0', true
    );

    // Envoyer une variable de PHP à JS proprement
    wp_localize_script('twentytwentychild', 'ajaxurl', admin_url('admin-ajax.php'));
}
add_action('wp_enqueue_scripts', 'twentytwentychild_asset');


add_action('wp_ajax_send_form', 'send_form'); // This is for authenticated users
add_action('wp_ajax_nopriv_send_form', 'send_form');

function send_form(){
    // This is a secure process to validate if this request comes from a valid source.
    check_ajax_referer( 'secure-nonce-name', 'security' );
 
    /**
     * First we make some validations, 
     * I think you are able to put better validations and sanitizations. =)
     */
     
    if ( empty( $_POST("name") ) ) {
        echo "Insert your name please";
        wp_die();
    }
 
    if ( ! filter_var( $_POST("email"), FILTER_VALIDATE_EMAIL ) ) {
        echo 'Insert your email please';
        wp_die();
    }
 
    if ( empty( $_POST("fcPhone") ) ) {
        echo "Insert your phone please";
        wp_die();
    }

    $to = 'test@gmail.com';

    $subject = 'Un potentiel consultant viens de faire une simulation!';

    $body  = 'From: ' . $_POST('name') . 'n';
    $body .= 'Email: ' . $_POST('email') . 'n';
    $body .= 'Message: ' . $_POST('fcPhone') . 'n';

    $headers = array('Content-Type: text/html; charset=UTF-8');

    wp_mail( $to, $subject, $body, $headers );

    echo 'Done!';
    wp_die();
     
}

and my template page
it’s a simple form :

<form action="" method="post" name="form_result">
    <div id="simulation_form">
        <div style="margin-bottom: 2rem; display: flex;">
            <div class="vc_col-sm-4">
                <div class="simulation_form_q">Votre name:*</div>
                <div class="simulation_form_r">
                    <input type="text" id="name" name="name" required>
                </div>
            </div>
            <div class="vc_col-sm-8">
                <div class="simulation_form_q">Votre email:*</div>
                <div class="simulation_form_r">
                    <input type="email" name="email" id="email" required>
                </div>
            </div>
            <div class="vc_col-sm-8">
                <div class="simulation_form_q">Votre numero de telephone:*</div>
                <div class="simulation_form_r">
                    <input type="text" name="fcPhone" id="telephone" required>
                </div>
            </div>
        </div>

        <input type="hidden" name="action" value="send_form" style="display: none; visibility: hidden; opacity: 0;"/>
        <div class="simulation_form_btn">
            <input type="submit" value="calculez vos revenus">
        </div>
    </div>
</form>

but when i send the Ajax request i have 403 error forbidden I don’t know why i clear the cache and the cookie i use console log to debug the ajax request and it send all the data yet i have still that 403 ERROR and i don’t know how to solve it

jquery – CREAR REGISTRO AJAX LARAVEL

Estoy intentando crear un modal que registre a una persona con su numero de celular, lo quiero hacer con ajax para que no me recargue la pagina ya que mas adelante habra un select que se alimentara en simultaneo con la info de la base de datos.
Esto es lo que tengo:

Ruta

Route::post('turnos/addDeliveryModal', (AppHttpControllersTurnoController::class, 'addDeliveryModal'))->name('turnos.addDeliveryModal');

Controlador

public function addDeliveryModal(Request $request){
    $delivery = New Delivery();

    $delivery->nombDelivery = $request->nombDelivery;
    $delivery->celDelivery = $request->celDelivery;

    $delivery->save();

    return response()->json($delivery);
}

Formulario modal

<form method="POST" id="addDeliveryModal">
                    @csrf                
                    <div class="modal-body">
                        <div class="form-group">
                            <label class="form-control-label">Nombre del Delivery</label>
                            <input type="text" name="nombDelivery" class="form-control form-control-alternative" required>                    
                        </div>
                        <div class="form-group">
                            <label class="form-control-label">Telefono o Celular</label>
                            <input type="text" name="celDelivery" class="form-control form-control-alternative" required>                    
                        </div>
                    </div>            
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-success">Guardar</button>
                        <button type="button" class="btn btn-danger  ml-auto" data-dismiss="modal">Cerrar</button>
                    </div>  
                </form> 

Ajax

$("#addDeliveryModal").submit(function(e){
        e.preventDefault();

        let nombDelivery = $("#nombDelivery").val();
        let celDelivery = $("#celDelivery").val();
        let _token = $("input(name=_token)").val();

        $.ajax({
            url: "{{route('turnos.addDeliveryModal')}}",
            type: "POST",
            data:{
                nombDelivery:nombDelivery,
                celDelivery:celDelivery,
                _token:_token
            },
            success:function(response)
            {
                if(response){
                    console.log("hola");
                }else{
                    console.log("hola2");
                }
            }
        });
    });

Screenshot del Formulario
introducir la descripción de la imagen aquí

Screenshot del error que me bota

introducir la descripción de la imagen aquí

El problema esta en que con lo que yo tengo hasta ahora me bota el error que esta en la ultima imagen, aun soy nuevo en esto espero me puedan hechar una mano.
Los leo…

ajax – Cómo validar el click de un botón desde javascript en php

var loginButton = document.querySelector("login-button");

loginButton.onclick = function() {
    
    parameters = {
        'user': loginPhone.value,
        'password': loginPassword.value
    };
    
    $.ajax({
        data: parameters,
        url: 'login.php',
        type: 'POST',
        
        success: function(mensaje) {
            
        }
    });
    
}


// EN PHP SE CREAN DATOS EN BLANCO, YA QUE PRIMERO VALIDO SI EXISTE LA CUENTA Y DESPUES INSERTO PERO NO, SIGUE CREANDO

$user = $_POST('user');
$password = $_POST('password');

$base->query("INSERT INTO $tabla (user,password) VALUES ('$user','$password')");
<button class="login-button"></button>

angular – Requisições Ajax Api Recita Web Service

Como retirara os dados fornecido pela Api pra fora da requisição Ajax?

        url: 'https://www.receitaws.com.br/v1/cnpj/53113791000122',
        dataType: 'jsonp',
        type: 'GET',
        success: function (data) {
            console.log(data);
        }
    });```

Ajax Error WordPress Theme Nginx Web Server


Your privacy


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.