Slasher
Slasher

Reputation: 618

Output json with using ajax

I'm new to ajax, and I quite don't understand how could I output json objects with console.log. Without added .val() output is working, but when I add .val() to the search query, it doesn't seem to work.

$( document ).ready(function() {
$(".form-inline").submit(doStuff);
});

function doStuff(e){
e.preventDefault();

var input = $("#nanizankaInput").val();
var link = "http://api.tvmaze.com/search/shows?q=";
link = link + input; 

$.ajax({
    url: 'link',
    method: 'GET',
    success: function (data) {
        console.log(data);
    }
});
}

FiddleJS: https://jsfiddle.net/Ld9f0ant/4/

Upvotes: 0

Views: 34

Answers (1)

Chris Lear
Chris Lear

Reputation: 6742

I don't think I've completely understood everything in the question, but I can see a problem with the code.

Maybe replace url: 'link' with url: link.

Upvotes: 4

Related Questions