jquery - $ is not defined when sending data with ReactJS -


i'm tryin send data reactjs form php:

handlesubmit(event){     $(function () {         $('form').on('submit', function (e) {             e.preventdefault();                 $.ajax({                   type: 'post',                   url: 'register.php',                   data: $('form').serialize(),                   success: function () {                     alert('form submitted');                   }                 });             });         }); } 

i got error message

'$' not defined

<script src="https://code.jquery.com/jquery-3.2.1.js" integrity="sha256-dzankj/6xz9si04hgrsxu/8s717jcizly3oi35eouye=" crossorigin="anonymous"></script> 

i install jquery npm

npm install jquery --save 

then add jquery componement app

import $ 'jquery'; 

and works.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -