This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

jesusvaz11281
jesusvaz11281

I am using javascript to call a function in my controller "onGradeQuestion". Once is call it want to update a partial with information returned in "data" but I don't have success.



function updateComponent(answer){


        console.log(answer);
        $('#getDatos').request('onGradeQuestion', { 
            data: {val:answer}, // this is the way to pass parameters to the onGradeQuestion function
            dataType: 'text',// returning info type. I returns an array

            update: {calcresult: '#result2'},// I use this to update partial but does not work

            success: function(data) {  //I am updating data with JS in this way but i want o use a partial
                var ans = answer;
                var datafromCode = document.getElementById(ans);

                //split returning array
                var comments  = data.split(",");
                var correct = comments[0];
                var incorrect = comments[1];
                var neutral =comments[2];
                //update html code
                datafromCode.innerHTML =  ""+correct+"
"+incorrect+"
"+neutral; datafromCode.innerHTML += "

"; }
 })


whats the correct way to render the partial once i call the function in the controller?

Last updated

SashaGontarev2744
SashaGontarev2744

try 'complete', not 'success'

jesusvaz11281
jesusvaz11281

thanks for the reply. please explain how it would render the partial on complete. I was not succesful

chris10207
chris10207

as per the documentation, if you implement the success method, then the update method wont be executed

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.