Reputation: 301
How to rewrite the code so I can use the JSON data retrieved from test2.php
?
function drawChart4() {
var jsonData = $.ajax({
url: "/master/test2.php?zoekopdracht=ceremonie",
dataType: "json",
async: false
}).responseText;
var object = $.parseJSON(jsonData);
Upvotes: 0
Views: 88
Reputation: 42935
Your question is not very clear, but maybe this is what you are looking for:
$.ajax({
url: "/master/test2.php?zoekopdracht=ceremonie",
dataType: "json"
}).done(function(jsonData){
// do something with the data
console.log(jsonData);
}).fail(function(){
// react on error
console.log("Whoops, that failed!");
});
This assumes you are using the jQuery JS library on the client side, which your code implies.
Upvotes: 1