Welcome Guest, Not a member yet? Register   Sign In
Failed to load resource: the server responded with a status of 500 (Internal Server E
#1

(This post was last modified: 02-07-2023, 10:42 PM by namalr.)

/Staffs/fetchTitleData:1          Failed to load resource: the server responded with a status of 500 (Internal Server Error)  when send ajax request ,but direct ling is working 

my ajax request in view
var uri="<?php echo base_url();?>/Staffs/fetchTitleData";
   
    $.ajax(
    {
        url:uri,
        method:"POST",
        data:{},
         
        error: function(data) {
          // alert(data);
            alert('Something is wrong'+ ' '+  data);
          },
        success:function (data) {         
          var options='<option value="">Select Title</option>  ';
              if (response instanceof Object) {
                $.each(response, function(index, value) {
                  $.each(value, function(index2, data) {
   
                    options+=data[2] ;
                  });
                });
              }
             
              $('#title').html(options);     
      }
    });

my controller method 
public    function  fetchTitleData()
    {
       
        $response = $data['data'] = array();

$titles =$this->staffsModel->getTitle();

foreach ($titles as $key => $value) {
$ops = '<option value="'.$value->tId.'">'.$value->tName.'</option>';


$data['data'][$key] = array(
$value->tId,
$value->tName,

$ops
);
}
return $this->response->setJSON($data);
       
    }

please help me 
i have got stuck in my application
Reply
#2

Check your web server log and CI4 log.
https://codeigniter4.github.io/CodeIgnit...error-logs
Reply
#3

(This post was last modified: 02-12-2023, 12:37 AM by InsiteFX. Edit Reason: add example )

If he's use base_url() and he's using the ending / slash then he doe's not need it in his ajax uri.

PHP Code:
var uri="<?php echo base_url('Staffs/fetchTitleData');?>"
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB