Failed to load resource: the server responded with a status of 500 (Internal Server E |
/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
Check your web server log and CI4 log.
https://codeigniter4.github.io/CodeIgnit...error-logs
02-12-2023, 12:35 AM
(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 )
|
Welcome Guest, Not a member yet? Register Sign In |