jquery - AJAX: can't call function on image click -


i have problem passing data post method in ajax.

ajax method :

$(document).ready(function(){   $("#vote").click(function(){     $.ajax({         type:'post',         async: false,          url: "http://localhost/psi/dokumentacija/faza5/implementacija/votes/votealg",          data: {             incdec: $("#vote").val(),             alg: $("#algcode").val(),         },         datatype: 'text',          cache: false,         success: function(mess) {             console.log(mess);             if(mess=='voted') {                 alert("glasali ste vec!");             } else if (mess=='error') {                 alert("problem sa bazom");             } else {                 $("#algrate").val(mess);             }          }     });      return false;    });  }); 

function in controllers :

public function votealg() {     if ($this->input->is_ajax_request()) {         $this->load->model('vote');         $this->vote->votealgdb();     }      else {         redirect('error_404');     }  } 

in model :

public function votealgdb() {     $id = $this->input->post('alg');     $incdec = $this->input->post('incdec');     $iduser = $this->session->userdata('iduser');     if($incdec=='inc') {         $broj = 1;         $this->insertvote($broj, $idalgorithm, $iduser);     } else if ($incdec = 'dec') {         $broj = -1;         $this->insertvote($broj, $idalgorithm, $iduser);     }      echo $this->shownumberofvotes($idalgorithm); } 

i error: http://postimg.org/image/wy3vgbcu7/

do have idea problem?

edit:

similar ajax function used before, , working well.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -