0

I want to make an ajax request and it wont work. This is my code:

function loadSingleProductPaso1(div_loading,div_id,index, json,ajaxurl){
$.ajax({
    type: "POST",  
    url: ajaxurl, //the url is http://www.mysite.com/controller/function
    data: "ajax=true&precio="+JSON.parse(json[index]).miprecio,
    success: function(msg){
             ...
            } 
    }
});  

}

The thing is, when I add a '?' to the data element (data: "?ajax=true&..."), it works, but sends a $_POST['?ajax'] variable.

I really don't understand what am I doing wrong.

4

1 に答える 1

0

ポスト関数を使用できます。

このような、

$.post(ajaxurl, {
   name : "Test",
   city : "Istanbul"
}, function(data){
   if(data == 1){
       alert("success!");
   }
});

function ajax(){
    if($this->input->post('name') == "Test"){
        echo 1;
    }
}
于 2012-04-12T15:09:31.843 に答える