ColdFusion 2016 Ajax

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

I'm stuck at simple issue.

On submit I send form with jQuery ajax to server. But I got response: 500 (Element MY_VAR is undefined in FORM.)

What I'm 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>

Upvotes: 4

Views: 155

Answers (1)

Tom Stroinski
Tom Stroinski

Reputation: 66

500 indicates an internal server error.

Are you trying to display your form values after sending them?

Maybe try and use the cfdump tag. Very useful for debugging.

Try dumping the form scope and see what variables are actually in there.

Upvotes: 4

Related Questions