rob.m rob.m - 1 year ago 96
jQuery Question

getJSON not outputting the html data into a div

If I try to output that getJSON in

is fine, i see it, yet it doesn't go into the div as I am expecting to.

Trying this:

page:"Football", prop:"text"
}, function(data) {

<div class="modal-content"></div>

NOTE: console gives no error and div is empty

Answer Source

You have to access the text property of the returned object correctly. Just trying to set .html(.. by passing the returned object will not work, because jquerys .html() method expects a function or a string as the parameter.

According to wikis API:JSON version 2 you can add the following property to the options object passed to $.getJSON.


Eliminate useless indirection, e.g. {"text":"..."} instead of {"text":{"*":"..."}} and {"key1":"value1","key2":"value2"} instead of [{"name":"key1","*":"value1"},{"name":"key2","*":"value2"}].

So here is the correct anwser.

var location = "";

$.getJSON(location, {
  formatversion: 2
}, function(data) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download