4

Is is possible to use AJAX on an onblur event from a textfield. I'd like html (inside a div container) to change whenever I tab out of a textfield. I see a lot of questions/tutorials using AJAX with forms but not on the individual components such as textfield or checkbox.

1 Answer 1

11

You can do it using plain JQuery. Assuming your form element has the ID of my_element:

$("#my_element").blur(function(){
  $.ajax({url: '/my/data', type: 'GET'})
  .done(function(response){
    $("#my_div").html(response);
  })
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.