I will explain this description.
 In $ (*****), describe the class name of form.
 Describe the event name in .on (***** ,.
 In e.preventDefaul, the default event is stopped for asynchronous communication.
## Let's use Ajax to get messages # create to work when the event fires
 
 This in this description contains information about the Form that fired the event.
 $ (this) .attr ('action'); is getting the path of Form information.
# Let's save the message with the #create action of the messages controller and use respond_to to return the response to the JSON format request
 
if @message.save
 Saves the information sent in the request
 respond_to do |format|
        format.json
 Returning in json method
## Other output
 
 HTML is added to the class name MessageField with append (html)
 $(".submit-btn").prop('disabled', false);
 If you press the send button once, you will not be able to press it unless you reload it.
 By writing prop ('disabled', false); in the submit button class, you can post without loading.
## Processing when asynchronous failure
 
 If it fails, it will alert you of the error.
 Used after Done
        Recommended Posts