ColdFusion 2016 Ajax

I'm trying to figure out what Adobe Coldfusion is and how to work on this platform.

I am stuck in a simple problem.

On submitting, I submit the form with jQuery ajax to the server. But I got the answer: 500 (the MY_VAR element is undefined in FORM.)

What am I doing wrong?

Js

$loginForm.on('submit', function(e) {
    e.preventDefault();
    var formData = new FormData(e.target);
    $.ajax({
        url: 'test.cfm',
        method: 'POST',
        cache: false,
        processData: false,
        data: formData,
        error: function(err) {
            console.log(err);
        },
        success: function(data, status) {
            console.log(status);
            console.log(data);
        }
    });
});

CF

<cfoutput>
  <p>#form.myvar#</p>
</cfoutput>
+4
source share
1 answer

500 indicates an internal server error.

Are you trying to display your form values ​​after they are submitted?

Perhaps try using the cfdump tag . Very useful for debugging.

Try resetting the form area and see which variables are actually there.

+4
source

Source: https://habr.com/ru/post/1690135/


All Articles