I have written html page which takes an input from user and on click submit calls a javascript function. The html page is given below:
<body>
<input type="text" id="input_"/>
<input type="button" id="submit" value="Get tweets"/>
<div id="results"></div>
</body>
and the javascript is:
$("#submit").click(function() {
$.getJSON("tweets.php?q="+$('#input_').val())
.done(function(data) {
console.log(data);
})
});
the url in .getJSON is actually localhost/tweets.php?q=(userInput) but the url doesnt return anything in getJSON.done function however if i use .fail(err) and display err on console it prints the returned data on console. Also if I manually open for example: localhost/tweets.php?q=mkx on browse the data is displayed on browser. I cant seem to find any problem in the code. The tweets.php file is below:
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$getfield = '?q=%23'.$_GET["q"];
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
echo $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest(true);
Any help would be appriciated.