Asynchronization of message transmission

Let the event fire when the form is submitted

スクリーンショット 2020-07-03 22.12.39.png 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 スクリーンショット 2020-07-03 22.17.55.png 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 スクリーンショット 2020-07-03 22.21.45.png if Saves the information sent in the request respond_to do |format| format.json Returning in json method ## Other output スクリーンショット 2020-07-03 22.25.20.png 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 スクリーンショット 2020-07-03 22.31.17.png If it fails, it will alert you of the error. Used after Done

Recommended Posts

Asynchronization of message transmission
[FCM] Implementation of message transmission using FCM + Spring boot
Going out of message (Spring boot)
About the error message Invalid redeclaration of'***'
Unexpected behavior of default message in org.springframework.context.MessageSource.getMessage ()