danjapro Posted September 19, 2014 Share Posted September 19, 2014 Please help with this, it not going to the .html controller and returing the values need, it captures the email form values, bu then fails with a 406 error. Please help $('#newsletter').submit(function() { //E-mail is passed var values = $(this).serialize(); var formRef = $('form').attr('id'); var dataString = JSON.stringify(values); //var values = $("#newsletter_email").val(); if($('#newsletter_tc_check').is(':checked')){ $.ajax({ type: 'POST', url: "./saveNewsletterSignupEmailPost.html", dataType: 'json', data: dataString, contentType: 'application/json', mimeType: 'application/json', success: function(data) { var result = $.parseJSON(data); if(result.form == formRef){ $('.success.message').contents().find('h4').text(success.text()); VanillaReload.notify.showNotification("success"); $("#newsletter_email").val(""); }else{ $('.error.message').contents().find('h4').text(error.text()); VanillaReload.notify.showNotification(".error"); } } }); return false; }else{ $('.error.message').contents().find('h4').text(error.text()); vanillaeGift.notify.showNotification(".error"); } return false; }); Quote Link to comment https://forums.phpfreaks.com/topic/291166-ajax-failing-with-406/ Share on other sites More sharing options...
CroNiX Posted September 19, 2014 Share Posted September 19, 2014 Shouldn't saveNewsletterSignupEmailPost.html be a php script to process the data? HTML files can't do that. Quote Link to comment https://forums.phpfreaks.com/topic/291166-ajax-failing-with-406/#findComment-1491599 Share on other sites More sharing options...
cyberRobot Posted September 19, 2014 Share Posted September 19, 2014 Shouldn't saveNewsletterSignupEmailPost.html be a php script to process the data? HTML files can't do that. It depends on the server setup. HTML files can be set to be interpreted as PHP scripts. However, you may still have a point. Quote Link to comment https://forums.phpfreaks.com/topic/291166-ajax-failing-with-406/#findComment-1491608 Share on other sites More sharing options...
CroNiX Posted September 19, 2014 Share Posted September 19, 2014 Yes if he added an AddType handler or equiv if not Apache, but in my experience it's pretty rare. I'm assuming due to the 406 response code that it isn't set up that way. Quote Link to comment https://forums.phpfreaks.com/topic/291166-ajax-failing-with-406/#findComment-1491609 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.