JQuery Ajax POST in Codeigniter
$(document).ready(function(){
$("#send").click(function()
{
$.ajax({
type: "POST",
url: base_url + "chat/post_action",
data: {textbox: $("#textbox").val()},
dataType: "text",
cache:false,
success:
function(data){
alert(data); //as a debugging message.
}
});// you have missed this bracket
return false;
});
});
How does Codeigniter receive the ajax post data in controller
Change your ajax this:
$.ajax({
url : "<?php echo base_url(); ?>welcome/login"
type : "POST",
dataType : "json",
data : {"account" : account, "passwd" : passwd},
success : function(data) {
// do something
},
error : function(data) {
// do something
}
});
Change your controller this:
public function login() {
//$data = $this->input->post();
// now I can get account and passwd by array index
$account = $this->input->post('account');
$passwd = $this->input->post('passwd');
}
I hope this work for you...
send data from ajax to controller codeigniter
Try this. see if it works. Just using "type" instead of "method"
var day = $(obj).text();
var base_url = $('#baseurl').val();
$.ajax({
type: 'POST',
url: base_url + "Front_end_controller/eventi",
data: {date: day},
success:function(result) {
alert(result); // alert your date variable value here
},
error:function(result) {
console.log(result);
}
});
And in your controler :
public function eventi()
{
$day = $this->input->post('date');
if(!empty($day))
{
echo $day;
}
else
{
echo "No Data";
}
}
How to get data from controller to view using ajax in codeigniter
yes it will give you error when you use data type json. it means that on ajax call the data will be pass to controller in json format..
while you are passing a simple post data...
remove the datatype json. every thing is ok...
and more mistake use this line
url: "<?php echo base_url(); ?>/contorller_name/employee_master/"+id,
Related Topics
Session Share Across Multiple Domains on Same Server
Passing and Parse Paypal Ipn Custom Field
Html2Pdf in PHP - Convert Utilities & Scripts - Examples & Demos
Differencebetween .= and += in PHP
Printing PHP Script Output to File
Fatal Error: Call to Undefined Function MySQL_Connect() in C:\Apache\Htdocs\Test.PHP on Line 2
In Flutter Web Getting 'Xmlhttprequest' Error While Making Http Call
Ip Address Is Showing in Form Action with Codeigniter Http://::1/Codeigniter/ in HTML Sourcecode
Understanding PHP "Out of Memory" Error
Insert a Persian Text in MySQL Table
Moving from MySQL to MySQLi or Pdo
Woocommerce: Display Also Product Variation Description on Cart Items
How to Get Average of Column Values in Laravel
How to Launch a PHP Script at Apache Startup
How to Get List of Supported Encodings by Iconv Library in PHP