Parameters with Ajax

Asked

Viewed 27 times

0

hello, I’m trying to go through parameters with variables information of two Dropdown fields, but I’m not able to use two variables, when I use only one with you normally. following example:

$(function(){
$('#alerta_cor').hide();
$('#id_cod_item').change(function(){
if( $(this).val() ) {
$('#cor_prod').hide();
$('#alerta_cor').show();
$.getJSON('select_cor_prod.php?search=',{id_cod_item: $(this).val(), ajax: 'true'}, function(j){
var options = '<option value="">Escolha a Cor</option>';
for (var i = 0; i < j.length; i++) {
options += '<option value="' + j[i].id_cor + '">' + j[i].desc_cor + '</option>';
}
$('#id_cor_prod').html(options).show();
$('#alerta_cor').hide();
});
} else {
$('#id_cor_prod').html('<option value="">– Escolha o produto –</option>');
}
});

the problem is when I try to pass two variables does not present the information, ie does not work, I do not have much skill with ajax, so I believe I am doing something wrong in the declaration of variables. Below follows the line I changed to load two variables, they are id_cod_item and situaca_prod.

$.getJSON('select_cor_prod.php?search=',{id_cod_item: $(this).val(), situacao_prod: $(this).val(), ajax: 'true'}, function(j){

if anyone can guide what I’m doing wrong I appreciate.

att Ebert

  • Why this ?search= in the URL if you are not passing any value? Use callback .fail(function(){}) as described in documentation to see what is returning.

  • hello, it passes the input value ID="id_cod_item", the problem being to inform more than one ID to pass values.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.