my controller funnction
public function give_form()
{
if($this->session->userdata('use'))
echo "user";
else
echo "sassa";
}
i am calling this function with ajax my ajax code is this
function discount(){
alert('hi');
jQuery.ajax({
url: "<?php echo base_url(); ?>" + "index.php/home/give_form",
type: "post",
data: "cityy="+city,
success: function(response) {
alert(response);
}
});
}
i am not getting any result from controller funciton!!!
答案 0 :(得分:2)
试试这个 这对我有用
function discount(){
alert('hi');
$.ajax({
url: "<?php echo base_url(); ?>/index.php/home/give_form",
dataType: 'json',
type: "POST",
data: {cityy: city},
success: function(response) {
alert(response)
},
});
}
答案 1 :(得分:0)
更改您的ajax网址
url: "<?php echo base_url(); ?>" + "index.php/home/give_form"
到
url: <?php echo base_url(); ?> + "index.php/home/give_form"
答案 2 :(得分:0)
试试这个
function discount(){
alert('hi');
var base_url = window.location.origin;
jQuery.ajax({
url: base_url + "/index.php/home/give_form",
type: "post",
data: "cityy="+city,
success: function(response) {
alert(response);
}
});