I want to render an object from my controller to a jQuery callback function. That is how I try to do it:
Calling jQuery Ajax function
function addVideo() {
var url = "/myApp/project/addVideo"
var data = 'videoURL=' + $('#videoUrlInputText').val()
$.getJSON( url,
{
videoURL: $('#videoUrlInputText').val()
},
updateVideoLoad(data)
)
}
My Grails 'Project' controller
def addVideo() {
def videoMap = [urlAccepted: "bim", provider: "bam"]
render videoMap as JSON
}
My jQuery callback function (updateVideoLoad())
function updateVideoLoad(videoMap) {
$('h4').html( 'Provider: ' + videoMap.provider )
}
I end up getting the undefined output in the browser. Nothing in the browser console.
The controller output is tested and renders correctly the JSON object.
Any idea why the object is not read correctly by the callback function ? Any suggestion is most welcome.
Thanks in advance.