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

amazon web services – Ajax not receiving return data from server response

I work with an open source package call OpenEMR https://github.com/openemr/openemr/.

I am having a problem with the ACL display screen. It displays this error message.
ERROR, unable to collect data from server

This is a link to the code in reference.
https://github.com/openemr/openemr/blob/2e1087e3c371ee08268cd1e7777c6a76b10e7cfa/interface/usergroup/adminacl.php#L214

I have set traps on the server. The server is send/echoing out the XML. I have captured the XML in a file on the server. So, I know that server side is processing the request and sending a response.

//PROCESS USERNAME REQUESTS
if ($_POST("control") == "username") {
  if ($_POST("action") == "list") {
     //return username list with alert if user is not joined to group
      echo username_listings_xml($error);
   }
}

https://github.com/openemr/openemr/blob/2e1087e3c371ee08268cd1e7777c6a76b10e7cfa/library/ajax/adminacl_ajax.php#L51

The response is not making it back to the client. How do I troubleshoot the response from the server to the client? What could block the server response from reaching the client?

The server is on AWS and is Ubuntu 20.04. PHP 7.4 Apache 2.x.

Where should I be looking to fix this issue?

ajax – Como pegar um objeto JSON externo?

Eu tenho um programa que consiste em, eu clico num botão para validar o usuario, em seguida eu devo criar um php que trate dessa validação do usuario. em seguida eu tenho que passar a mensagem de confirmaçao por um objeto json, e mostrar se o usuario foi ou nao validado. eu ja tenho tudo feito, mas a parte de passar uma mensagem em json eu nao tenho ideia de como se faz
inserir a descrição da imagem aqui

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 – Problema con AJAX en MVC

Buen día, estoy trabajando con la arquitecturas MVC, y al querer hacer una petición AJAX a mi modelo para obtener los datos me salta un error que hace referencia a un archivo faltante, que en este caso sería el enrutador que conecta a mis modelos directamente con el archivo de conexión a la BD. Les muestro:

Archivo ajax/dashboard.php

<?php 
require_once "../models/dashboardModel.php"; //importo el archivo donde tengo mis consultas
$dashboard = new DashboardModel(); //Creo un objeto
$nombre = $_SESSION('nombre');
switch ($_GET("op")){

    case 'listar':
        $rspta=$dashboard->listar($nombre);
        $data= Array();
        while ($reg=$rspta->fetch_object()){
            $data()=array(
                "0"=>$reg->id_usuario,
                "1"=>$reg->nombre,
                "2"=>$reg->institucion,
                "3"=>$reg->carrera,
                );
        }
        $results = array(
            "sEcho"=>1, //Información para el datatables
            "iTotalRecords"=>count($data), //enviamos el total registros al datatable
            "iTotalDisplayRecords"=>count($data), //enviamos el total registros a visualizar
            "aaData"=>$data);
        echo json_encode($results);

    break;
}

Archivo js/charts.js

function listar() {
    tabla = $('#tblEstilosAprendizaje').dataTable(
        {
            "aProcessing": true,//Activamos el procesamiento del datatables
            "aServerSide": true,//Paginación y filtrado realizados por el servidor
            dom: 'frtBp',//Definimos los elementos del control de tabla
            buttons: (
                'copyHtml5',
                'excelHtml5',
                'csvHtml5',
                'pdf'
            ),
            "responsive": true,
            "lengthChange": false,
            "autoWidth": false,
            "ajax":
            {
                url: 'ajax/dashboard.php', //url de mi archivo ajax para obtener los datos de la tabla
                type: "get",
                dataType: "json",
                error: function (e) {
                    console.log(e.responseText);
                }
            },
            "bDestroy": true,
            "iDisplayLength": 5,//Paginación
            "order": ((0, "desc"))//Ordenar (columna,orden)
        }
    ).DataTable();
}

listar();

archivo models/dashboardModel

<?php

class DashboardModel extends Model //El error que me arrojará será por el extends Model
{
    function __construct()
    {
        parent::__construct();
    }

    public function listar($nombre)
    {
        try{
            $query= $this->query("SELECT u.id_usuario, u.nombre, i.nombre AS Institucion, c.nombre 
            AS Carrera FROM usuarios AS u INNER JOIN instituciones AS i ON u.institucion=i.id_institucion 
            INNER JOIN carreras AS c ON c.id_carrera=u.carrera WHERE tutor='$nombre'");
            $resultado = $query->fetchAll(PDO::FETCH_ASSOC);
            return $resultado;
        }catch(PDOException $e){
            $e->getMessage();
            error_log($e);
            return false;
        }
    }

El problema es, que al observar con el DevTools del navegador para ver si existen datos encontrando en mi archivo js desde el modelo, me arroja un error, que es este:

Fatal error: Uncaught Error: Class 'Model' not found in C:xampphtdocsTutoriasmodelsdashboardModel.php:3 Stack trace: #0 C:xampphtdocsTutoriasajaxdashboard.php(2): require_once() #1 {main} thrown in C:xampphtdocsTutoriasmodelsdashboardModel.php on line 3

que hace referencia a que no existe la clase “Models” que vendría siendo el que se encuentra en mi carpeta libs/models, y que esta misma hace conexión a la bd:

Archivo libs/models

<?php

class Model
{

    function __construct()
    {
        $this->db = new Database();
    }

    function query($query)
    {
        return $this->db->connect()->query($query);
    }

    function prepare($query)
    {
        return $this->db->connect()->prepare($query);
    }
}

Entonces, si llego a importarla directamente en mi modelo dashboard, me arroja los siguientes errores:

Warning: include_once(libs/model): failed to open stream: No such file or directory in C:xampphtdocsTutoriasmodelsdashboardModel.php on line 2

Warning: include_once(): Failed opening 'libs/model' for inclusion (include_path='C:xamppphpPEAR') in C:xampphtdocsTutoriasmodelsdashboardModel.php on line 2

Fatal error: Uncaught Error: Class 'Model' not found in C:xampphtdocsTutoriasmodelsdashboardModel.php:3 Stack trace: #0 C:xampphtdocsTutoriasajaxdashboard.php(2): require_once() #1 {main} thrown in C:xampphtdocsTutoriasmodelsdashboardModel.php on line 3

Quisiera saber qué es lo que me falta hacer o bien, que estoy haciendo mal. Muchas gracias de antemano y discuplen por el introducir la descripción de la imagen aquí

laravel – imprimir datos en chart.js con ajax

buen dia

quiero graficar los valores de unos pesos en mi pagina con chart.js ya tengo la grafica y se configurarla con los estilos y de mas pero no soy muy bueno en ajax y no se como traer datos desde mi base para poder mostrarlos en la grafica esto es lo que he intentado hasta el momento
estoy usando laravel

de antemano gracias a la persona que me pueda ayudar a solucionar

1:realizo una peticion a una ruta
aqui esta el ajax y el grafico todo en un solo script

$(document).ready(function() {

// obteniendo las maquinas y llenando el select
function pesos() {

    $.ajax({
        url: "{{ route('getpesos') }}",
        type: 'GET',
        dataType: 'json',
        success: function (response)  {
            
         response = pesos();
            
        },
        error: function () {
            alert('Hubo un error obteniendo los pesos!');
        }
    });
}

            var ctx= document.getElementById("myChart").getContext("2d");
            var myChart= new Chart(ctx,{
                type:"bar",
                data:{
                    labels:('col1','col2','col3'),
                    datasets:({
                            label:'Num datos',
                            data:(),
                            backgroundColor:(
                                'rgb(66, 134, 244,0.5)',
                                'rgb(74, 135, 72,0.5)',
                                'rgb(229, 89, 50,0.5)'
                            )
                    })
                },
                options:{
                    scales:{
                        yAxes:({
                                ticks:{
                                    beginAtZero:true
                                }
                        })
                    }
                }
            });
        </script>

          </div>
        </div>
        

2:ya tengo la ruta y la ruta me lleva al controlador donde hago la peticion a la base de datos

Route::get('publisher/getpesos',(enviosController::class, 'getpesos'))->name('getpesos');  /// ruta  

public function getpesos (){ /// controlador donde consulto los pesos

  try{
      $pesos = pesos::all();
      $respuesta = ('data'=>$pesos);
  }catch (Exception $exception){

      return response ()->json(('mensaje'=>'upps hubo un error'),500);
  }
  return response()->json($respuesta);

}

8 – How to render a view in an ajax callback

I am trying to develop a custom module to ajaxify the commerce form block. I tried using dc_ajax_add_cart and ajax_add_to_cart but they were not addapted to my project.

I have the following callback function

function tb_ajax_cart_reload_offcanvas_cart(array $form, FormStateInterface $form_state){

$response = new AjaxResponse();

// get current order id
$cart_provider = Drupal::service('commerce_cart.cart_provider');
$cart = $cart_provider->getCart('default');
$order_id = $cart->get('order_id')->getString();

// tried this
$cart_block = views_embed_view('commerce_cart_block', 'default',$order_id);
$response->addCommand(new ReplaceCommand('.commerce-cart-block', $cart_block));


// and this
$args = ($order_id);
$view = Views::getView('commerce_cart_block');
if (is_object($view)) {
    $view->setArguments($args);
    $view->setDisplay('default');
    $view->preExecute();
    $view->execute();
    $content = $view->buildRenderable('default', $args);
    $response->addCommand(new ReplaceCommand('.commerce-cart-block', $content));
}

//Alternatively I can reload the whole cart bloc but it is not what i am trying to do
$block = Block::load('cart');
if ($block != null) {
    $cart_block = Drupal::entityTypeManager()
         ->getViewBuilder('block')
         ->view($block);
    $response->addCommand(new ReplaceCommand('.navbar-cart>div', $cart_block));
}

return $response;
}

However it doesn’t work and I get stuck with the following error:

Render #pre_render callbacks must be methods of a class that implements DrupalCoreSecurityTrustedCallbackInterface or be an anonymous function.

I’ve read this post and others but I couldn’t figure out how to properly load the view inside my callback.

Any help is welcome. Thanks