2
I am working with jQuery to register information in the database through Ajax and do not know why this code is returning me a variable of the object type. The project I’m working on is being developed on top of a Admin Panel
with the entire interface and HTML, CSS e JS
ready. Here is the code:
$("#cadastra_produtos").submit(function(){
var prod_nome = $("#prod_nome");
var prod_categoria = $("#prod_categoria");
var prod_dimens = $("#prod_dimens");
var prod_qtde = $("#prod_qtde");
var prod_valor = $("#prod_valor");
var prod_descr = $("#prod_descr");
if(prod_nome) { alert(prod_nome); } <-- isso me retorna um objeto
The only particularity of this form that I think could be generating some type error is the plugin chosen-select
that is part of the system front-end.
You can help me figure out why Alert shows me an object and not the string?
Missed catching the
.val()
of all fields. The object you are seeing is the jQuery object that wraps the field in question.– bfavaretto
Note:
if(prod_nome)
never will fall into theelse
.– bfavaretto
Nooooooooooooooooossa forgot the
val()
– Marcos Vinicius