Uncaught TypeError: Cannot read property 'message' of undefined

30,879

The error is because responseJSON isn't a standard property or one that jQuery makes available for XMLHttpRequests.

You'll want to use responseText instead, which may be parsable:

contactForm.addAjaxMessage($.parseJSON(response.responseText).message, true);

// or
contactForm.addAjaxMessage(response.responseText, true);
Share:
30,879
Admin
Author by

Admin

Updated on March 11, 2020

Comments

  • Admin
    Admin about 4 years

    I am trying to implement an AJAX contact form for my site, the problem I am encountering is that when I click on submit I get the following error in Google Chrome:

    "Uncaught TypeError: Cannot read property 'message' of undefined----contact-form.js:38".
    

    Please find the HTML code and contact-from.js.