I'm trying to pass the variable var_nome to a php file using the code bellow. The value of this var is coming from a text field in a html form. If the value of the field is a number, it works perfectly and I get the data on teh php page BUT if the value of var_nome is a text, I got 'NaN' as a result?
function AlteraNomePortfolioAjax(portfolios_id, var_nome, SuccessDiv) {
$.ajax({
type: 'POST',
dataType: 'text',
url: 'PRT_ope_ajax.php',
data: {
'portfolios_id': +portfolios_id,
'var_nome': +var_nome
},
cache: false,
success: function(data) {
$(SuccessDiv).html(data);
}
});
}
</div>
Remove that +
sign, it is attempting to convert the variables to an integer:
data: {'portfolios_id' : portfolios_id , 'var_nome' : var_nome },