André Carvalho André Carvalho - 1 year ago 74
HTML Question

Why my Ajax not working

I'm try to use the Marvel API to do a school work and I did a function to do request to the Marvel server but I only receive the following object:
What is the problem?

function GetComic() {
var publicKey = 'e99561b7db2b414b085c39de1c7ed4ab';
var privateKey = 'dc00398114b3a9a4fbd20d8a318d54530c11659f';
var timestamp =;;
url: '',
type: 'GET',
dataType: 'json',
data: {apikey: publicKey, hash: md5(timestamp+privateKey+publicKey),ts: timestamp}
.done(function() {
.fail(function(r) {
.always(function() {



Answer Source

Your ajax function seem to correct but I did't see where you define the response for it so try this. Then we'll see what you get.

.done(function(response) {


You said that your ajax not work when you add button. It's because when you use the button it's will submit your form then the page is reload. So to make it's not submit the form. You can just easy edit your click event like this.

$('#btSearch').click(function(e) {
    e.preventDefault();  //add this line to prevent form to submit
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download