With jQuery AJAX how get name field writed in thank you message

Something like get the value

var name = $('#name').val();

But I not got that how can write this name include on succesfully sent message like with AJAX include success function:

success: function() {
$('#u_touch_general').html('thank you '+ name');

Something this but not work any idea?

Your success function should receive a parameter with whatever it needs.


success: function(data) { $('#u_touch_general').html('thank you '+ data.name); }

1 Like

Take a closer look at your syntax in here: $('#u_touch_general').html('thank you '+ name'); especially at the ' after name

1 Like

Still a question please!

I have $('#test').on('submit', function(e) {
inside it I have $.ajax but where I can put the var name = $('#name').val(); ?

On thank you message write undefinied.