![]() |
load a view php with ajax on a div - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 2.x (https://forum.codeigniter.com/forumdisplay.php?fid=18) +--- Thread: load a view php with ajax on a div (/showthread.php?tid=251) |
load a view php with ajax on a div - buraksensoz - 11-14-2014 Hello Pals i try load a view with ajax but innerhtml command has an error : Fatal error: Using $this when not in object context in C:\xampp\htdocs\application\views\signuppanel.php on line 3 ![]() How can i load this php? do you any example page for this ? if you want to see this error i linked my project on google drive you click signup button for error. google drive proje Link thnx RE: load a view php with ajax on a div - Chroma - 11-14-2014 Without seeing your code it is hard to say, but I am guessing, you are not fully initializing the CI framework before accessing the view. Is this correct? Do you have a special controller for the Ajax requests? RE: load a view php with ajax on a div - buraksensoz - 11-17-2014 (11-14-2014, 09:05 AM)Chroma Wrote: Without seeing your code it is hard to say, but I am guessing, you are not fully initializing the CI framework before accessing the view. Thanks for answer. I attached a link to my code at my previous message. You can check from there. About ajax: yes I have a special controller for requests. I don't know about framework, is it fully installed or not? How can I check it? By the way, as I said before, you can check the code from link. Download it and check from localhost. Try yourself please. Thank you! RE: load a view php with ajax on a div - buraksensoz - 11-17-2014 (11-14-2014, 09:05 AM)Chroma Wrote: Without seeing your code it is hard to say, but I am guessing, you are not fully initializing the CI framework before accessing the view. Thanks for answer. I attached a link to my code at my previous message. You can check from there. About ajax: yes I have a special controller for requests. I don't know about framework, is it fully installed or not? How can I check it? By the way, as I said before, you can check the code from link. https://docs.google.com/file/d/0B88OtgNiR5wlV2dJRkxkU0xxTzA/edit Download it and check from localhost. Try yourself please. Thank you! RE: load a view php with ajax on a div - Rufnex - 11-17-2014 I would recommend to put the files somewhere in raw format instead of a download. From the errror you try to use $this inside your view without a proper object. So maybe the view and the coresponding controller would be usefull to see (post it her inside a code bracket). RE: load a view php with ajax on a div - slax0r - 11-17-2014 This issue has already been fixed on IRC. He tried to $this->lang->line("key"); from within the view. Solution was to load the language helper and use the function lang() from the helper. RE: load a view php with ajax on a div - Rufnex - 11-17-2014 @slax0r: thx for feedback .. tilt it out of my mind ;o) RE: load a view php with ajax on a div - buraksensoz - 11-17-2014 (11-17-2014, 03:45 AM)Rufnex Wrote: I would recommend to put the files somewhere in raw format instead of a download. hi i attached my code. if i load signuppanel.php its working good but i load via ajax its not found lang() function. thnx again RE: load a view php with ajax on a div - slax0r - 11-17-2014 As it has been already said on IRC, you are not loading the language helper in the right point. All AJAX requests most go through the controller/model/view as all other normal request. An AJAX request is in its base exactly the same as if you would type in an URL in the browser. Unless you are sending some POST data over with AJAX, but even then, it is the same. So, if you call an URL like: http://yoursite.com/index.php/User/SignUp this means, that you are calling controller "User" and method "SignUp". It is in this controllers constructor method (public function __construct()) or in the controller method SignUp, where you must load the language helper with $this->load->helper("language");. Or, if you are using the language helper more frequently on more than this one view, you may want to add it to "application/config/autoload.php", where you add the "language" to the $autoload["helper"] array, like this: Code: $autoload["helper"] = array("language"); You must never call the view directly, the request must always go through a controller method. If you call it directly, there is nothing from CodeIgniter available there. RE: load a view php with ajax on a div - Chroma - 11-17-2014 (11-17-2014, 03:48 AM)slax0r Wrote: This issue has already been fixed on IRC. Thank you for the feedback and understanding of the issue. |