Problem with ajax request

Asked

Viewed 34 times

0

I have a problem with my ajax, I need to check on another page if a time is available. I select the consultant field and type the day, after that by clicking the button, it should bring a return whether it is free or busy, but it is not doing.

It goes down as it was and as I’m trying to do.

<a href="#" onClick="var myAjax = new Ajax.Updater('agenda_horario', '/php/clientes/carrega_horario_consultor.php?id_consultor='+document.forms[0].id_consultor.value+'&data_agendamento='+document.forms[0].data_agenda.value+'&id_franquia=<?=$id_franquia?>', {method: 'post', parameters: 'foo=bar'})" class="btn btn-confirma">Verificar hor&aacute;rios ocupados</a>

I’m trying to do

function carregaHorario() {



    var myAjax = new Ajax.Updater('agenda_horario', '/php/clientes/carrega_horario_consultor.php?id_consultor='+document.forms[0].id_consultor.value+'&data_agendamento='+document.forms[0].data_agenda.value+'&id_franquia=<?=$id_franquia?>',
    {
        type: 'POST',
        dataType: 'json',
        parameters: 'foo=bar'
    })

}

Following error appears

Uncaught TypeError: Cannot read property 'value' of undefined
at HTMLAnchorElement.onclick (VM2462 a_controle_visitas1a.php:834)

I hope you can help me, thank you.

  • You shouldn’t call the function charge somewhere, like in the onclick of button??

  • Exact, on onclick, just call the function carregaHorario(). And on the bug, it’s stating that you’re pulling the . value property of something that doesn’t exist. In its code this property presents twice, one linked to id_consultor and the other to data_agenda. Make sure both values are getting some value before they are called in ajax.

  • Whoa, whoa, thank you. that’s right, I’m using a button: <a href="#" onClick="loadHorario()" class="btn btn-confirms">Checkhor&aa;busy rivers</a> How could I receive this id_consultant and data_schedule ?

No answers

Browser other questions tagged

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