json_encode view returns null |
Dear CI Masters,
I don't know if I found a bug or I'm just don't get it. Jquery makes a post to a CI Controller: Code: $.post('/update_uri',{var:val},function(return){ The Controller: PHP Code: $result['pageX'] = $this->load->view('pageX','',TRUE); Can somebody confirm this? Thanks in advance
Use Network Monitor in your browser's developer tools and check if calling url is correct and how does response look like
view returns data as a string
please check "Returning views as data" section in View documentation. http://www.codeigniter.com/user_guide/ge...ws-as-data (08-13-2015, 12:42 AM)gadelat Wrote: Use Network Monitor in your browser's developer tools and check if calling url is correct and how does response look like Thanks for your reply. I found the issue by myself. It's because json_encode requires UTF8 string. So this works: Code: $result['pageX'] = utf8_encode($this->load->view('pageX','',TRUE));
With jQuery you should always use the full path:
PHP Code: <head> Then use the base_url or site_url in you jQuery code. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(08-13-2015, 04:22 AM)InsiteFX Wrote: With jQuery you should always use the full path: Thanks for this hint. I'm going to change that in my project. |
Welcome Guest, Not a member yet? Register Sign In |