Concatenate second data Ajax jQuery [duplicated]

0

I am currently sending Ajax % of%, but I need to send another data:

//data que necesito enviar
var ParamObjSend = {

    "id" :$("#id").val(), 

};

var array = [1,2,3,4];

$.ajax({
    type: "POST",
    url: "<?php print base_url();?>Controller/Guardar",
    data: {"array": JSON.stringify(array), ParamObjSend}, //de esta forma sigue sin funcionar      
    success: function(objView){
        alert("entro");
    }
}); 

When I send it, I can not capture it with Array :

public function Guardar () {    

    $dataPost = $this->input->post('id');//no llega

}
    
asked by Javier Antonio Aguayo Aguilar 11.05.2017 в 14:56
source

1 answer

0

You were close !, in data there are all the values that you must send. I'll put the example of Ajax :

$.ajax({
    type: "POST",
    url: "<?php print base_url();?>Controller/Guardar",
    data: {
        "array"       : JSON.stringify(array), 
        "status"      : true, 
        "miotrovalor" : 122,
        ParamObjSend
    },
    success: function(objView){
        alert("entro");
    }
});
    
answered by 11.05.2017 / 15:01
source