mousecoder mousecoder - 11 months ago 48
Ajax Question

jQuery get changing the URL parameter itself

I am making a get request using jquery to the local server in Flask. Here is the endpoint in Flask

@app.route('/getNews', methods=['GET', 'POST'])
def getNews():
return jsonify(news['news'])

Here is the call from HTML

success: function(data){
news = data;
dataType: "json"

Something annoying and very strange is happening. It keeps on giving me this error:

jquery-1.11.0.min.js:4 GET[object%20Object] 404 (NOT FOUND)

I have no clue why is it changing the address by itself. Any idea?


Your url argument is a string, not in the data object. The second argument is the data you are passing to the endpoint. The third argument is the success handler. And the last argument is the datatype expected back.

$.get( "", 'd', function( data ) {
      news = data;
    }, "json");