Change your code to:
$.get("/taylor", args, function(resultado) {
console.log(resultado)
});
Note: {args}
is invalid syntax. args
is already an object, so you don't need to wrap it in any other brackets.
Pergunta
I want to code an html button with jQuery, when chart
button is pressed, will take values from some text inputs, prepare a json of them and will perform a get request including the json with values.
$(".chart").click(function(){
var args = {}
args['fx'] = $("#tolerancia").val()
args['a'] = $("#a").val()
args['b'] = $("#b").val()
args['tolerancia'] = $("#tolerancia").val()
args['iteracionesMaximas'] = $("#iteracionesMaximas").val()
$.get("/taylor",{args},function(resultado){
console.log(resultado)
})
})
I'm getting an Invalid object initializer
message in console right on line of:
$.get("/taylor",{args},function(resultado){
What have I got wrong?
Solução
Change your code to:
$.get("/taylor", args, function(resultado) {
console.log(resultado)
});
Note: {args}
is invalid syntax. args
is already an object, so you don't need to wrap it in any other brackets.