jquery - ERR_EMPTY_RESPONSE in PATCH AJAX request in React-Rails -


i'm trying update basic database via form in app. update handled through ajax call:

handleupdate (e) {   let url = '/sites/' + this.props.site.id;   let site = {     name: this.refs.name.value,     city: this.refs.city.value,     state: this.refs.state.value,     country: this.refs.country.value,   };   e.preventdefault();   $.ajax({     method: 'patch',     url: url,     data: {site: site},     success: (site) => {       console.log("success");     }   }); } 

controller:

def update      @site = site.find(params[:id])      if @site.update_attributes(site_params)          redirect_to('index')      else          render('edit')      end  end 

when click update, receive error:

patch http://localhost:3000/sites/2 net::err_empty_response jquery.self-660adc5….js?body=1:10246

however, when refresh page, update made database, , updated value shown.

any ideas why happening? thanks!


Comments