Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm converting a site from ColdFusion to Lucee (for the first time). In ColdFusion, after using the cfajaximport tag, I can run JS code similar to this: ColdFusion.Ajax.submitForm('runMe', 'runCode.cfm', callback_testMe, errorHandler_testMe);

I seem to be unable to run this in Lucee. I'm looking for some kind of Lucee alternative, but can't seem to find anything.

Basically, I'm wanting to submit form data, run some server side stuff, then return the results without refreshing the page.

Any help would be greatly appreciated.

question from:https://stackoverflow.com/questions/66051194/lucee-coldfusion-ajax-submitform

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
136 views
Welcome To Ask or Share your Answers For Others

1 Answer

Lucee does not have CF UI tags, you're going to have to do this with jQuery AJAX or similar.

var formID = "runMe"; // formId Param
$("#"+formID).on("submit", function (e) {
    e.preventDefault(); // Prevent page load
    $.ajax({
        type: "POST", // httpMethod Param
        url: "runCode.cfm", // URL Param
        data: $(this).serialize(),
        success: function (data) {
            console.log(data); // callbackhandler
        },
        error: function (xhr, ajaxOptions, thrownError) {
            console.log(thrownError); // errorHandler
        }
    });
})

This should do exactly the same thing and I even pointed out the similar params from ColdFusion.Ajax.submitForm


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...