Response from Php File to Ajax is not getting sent

Question

I am trying to send some response from Php script to Ajax, but it is not getting sent.Below is my code.

For now I am sending dummy data which I will change later..

Php Script..

        $response = ['Successfull callback','ndnvnvnsobdboi','ijjijbujbhu'];
       
        echo json_encode($response);
        
        die();

Ajax Script…

jQuery(document).ready(function($){
$("#login_otp_btn").click(function(event){
    val();
  event.preventDefault();
  jQuery.ajax({
            url: wpac_ajax_url.ajax_url,
            type:'POST',
            data :{
                dataType:'JSON',
                action : 'login_ajax_callback',
                login : $("#login_mobile").val(),
                
               success:function(response){
                    console.log("url wpac " + wpac_ajax_url.ajax_url); 
                    if(!response == ""){
                    response = JSON.parse( response );
                    console.log(response);
                    }else{
                        console.log("Response is empty");
                         }
                    },
                    });
                    $("#login_otp_field").show();   
                    })
                }); 

I am getting Response is empty in my Console window. Which is in else statement

0
Shehryar 2 years 2020-12-22T06:10:29-05:00 0 Answers 4 views 0

Leave an answer

Browse
Browse