CodeIgniter Forums
JQuery post parameters do not get to my controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: JQuery post parameters do not get to my controller (/showthread.php?tid=61267)

Pages: 1 2


RE: JQuery post parameters do not get to my controller - reshadi - 12-08-2015

Try to use 

var_dump($_GET);

instead of var_dump($_POST).

Yours


RE: JQuery post parameters do not get to my controller - savitasandeep - 06-13-2017

When you get ajax problems you should view your "Console" window of Chrome browser. More over apply the .fail() deferred method to catch any errors encountered by ajax call. To apply jQuery Post method use the following code. Note I have passed nameValue to controller and used .done() and .fail() which are deferred objects in jQuery.

Code:
var url = $("#form_id").attr('action');
$.post(url,
   {
       nameValue: $("#new_loc_loc_name").val()
   })
   .done(function (result, status, xhr) {
       alert(result)
   })
   .fail(function (xhr, status, error) {
       alert(status + " " + error + " " + xhr.status + " " + xhr.statusText)
   });