Answer the question
In order to leave comments, you need to log in
What is the correct way to pass parameter to get JSON by URL?
Hello.
By sending ajax request to url trying to get json
works fine if done like this
http://localhost:8000/Forward?URL=dataset/employees.jsp?selected_region=Краснодар
$.getJSON( "Forward?URL=dataset/employees.jsp", { selected_region: selected } )
.done(function( json ) {
console.log("Список возможных позиций");
console.log(json);
})
.fail(function( jqxhr, textStatus, error ) {
var err = textStatus + ", " + error;
console.log( "Request Failed: " + err );
});
Request Failed: parsererror, SyntaxError: Unexpected token < in JSON at position 24
Answer the question
In order to leave comments, you need to log in
In the browser console, check what exactly is returned by the request. It looks like it's html instead of JSON.
And it’s better to add a leading slash to the address so that it works not only on the main one.$.getJSON( "/Forward?URL=dataset/employees.jsp"...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question