javascript - Get a ID from URL in another Function -


my question simple... see code:

my autocomplete:

$("#produto").autocomplete({     source: '/pedidoonline/index.php/pedidos/search/' + $('#codigo_fabricante').val(),     minlength: 2,     focus: function(event, ui) {         $("#produto").val(ui.item.label);         return false;     },     select: function(event, ui) {         $('#procura_produto').val(ui.item.id);         preencherlinhaproduto(ui.item.id);     } }); 

other function recieves codigo_fabricante: function in controller:

public function search() {     $this->autorender = false;     // consultando pelo que o usuário está digitando     $term = $this->request->query ['term'];     //this way isn't working, tried ['pass'][0] either.      $fabricante = $this->request->params['pass'];     echo($fabricante);     $this->loadmodel ( 'procuraprodutopedonline' );     $produtos = $this->procuraprodutopedonline->find ( 'all', array (             'limit' => 20,              'fields' => array (                     'cd_cpl_tamanho',                     'ds_produto'             ),             'conditions' => array (                     'cd_fabricante' => "$fabricante",                     'ds_produto like' => '%' . mb_strtoupper ( $term ) . '%'             ) )); 

i want value of + $('#codigo_fabricante').val() on function "search()" $fabricante recieves... how can ?

you need send argument pass (that retrieving in server side) query string value in url calling in js code:

'/pedidoonline/index.php/pedidos/search?pass=' + $('#codigo_fabricante').val() 

js

$("#produto").autocomplete({     source: '/pedidoonline/index.php/pedidos/search?pass=' + $('#codigo_fabricante').val(),     minlength: 2,     focus: function(event, ui) {         $("#produto").val(ui.item.label);         return false;     },     select: function(event, ui) {         $('#procura_produto').val(ui.item.id);         preencherlinhaproduto(ui.item.id);     } }); 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -