jquery - JavaScript in CakePHP's controller -
In my cake php view, I call the method in jQuery using jQuery in the controller:
function placeSensors (Nk) {$ .ajax ({type: 'post', url: '/ myapp / maps / placeSensors /' + nk, success: function (r) {if (r.status = 'ok ') {}}}); } JS in the controller ie Defined with:
Class MapsController Extended AppController {var $ name = 'Maps'; Var $ assistants = array ('js'); Var uses $ = array ('Measurings', 'Maps'); Var $ components = array ('RequestHandler'); // Added later, but still the same function index ($ id = null, $ value = null) {$ code = ''; ? & Gt; & Lt; Script type = "text / javascript" & gt; Warning ('hello!'); & Lt; / Script & gt; & Lt ;? Php return $ code; } So, with simple code, I can not get the warning message on my web form, the very simple code I was using in another project and it works there, and For some reason it does not work on this ...
I am actually living with this one, can you please help me .....
Update: I'm reacting to Firebug: & lt; Script type = "text / javascript" & gt; Warning ('hello!'); & Lt; / Script & gt;
You are trying to install a code that should be viewed by the customer (Javascript), the controller for commercial logic inside a controller, which the customer does not see.
Place your Javascript in a javascript file in the / webroot / js / directory.
To interact with AJAX, tell your controllers to use the component to determine that they are able to return simple prices from the AJAX they are calling, or a Jason or XML can return the scene.
If it looks complicated, do not worry about it now and just start it with ease and gradually build your application.
Comments
Post a Comment