JQuery form submission and CakePHP controller -


I am using CakePHP and jQuery for my application.

My jQuery code is:

  $ (document) .ready (function () {var str, fields; function showValues ​​() {str = $ (" $ ("Input"). $ ("Input"). $ ("Input") changes (show); show (); $ ("submit.") Click Do (function () (alert (str); $ .ajax ({type: "POST", Url: "http: //localhost/cake_1.2.1.8004/index.php/results/submit1", data: "str = "+ Str, success: function (msg) {warning (" data saved: "+ message);}}); // Ajax return false;}); // submit}}; // ready  

ANT when submitting a function while clicking inside Displays the thing. _method = POST and name = a

But when I post this value and retire it in the controller, its display only _method = POST ..

My contribution roller code is such,

submit the function1 ($ id = null) {echo "ctrller In ". $ _ POST ['str'];}

How to get the full value in the controller and save it or what is the way to recover it?

parameter parameter for $ ajax call takes a string in this format :

param1 = val1 and param2 = val2

Now, you are already creating strings in this format $ ("form") In sequence () .; Therefore, the correct way to allocate it is:

  $ .ajax ({type: "POST", url: "http: //localhost/cake_1.2.1.8004/index.php < / Code> 

Then your administrator can inspect the $ _POST array for the parameter you are looking for.

or print a post 'ad parameter as the query string :

  echo http_build_query ($ _ POST);  

Comments