每次我尝试运行app.rb时都会遇到这些错误
jquery.min.js:2 GET http://localhost:4567/water-level.json 404 (Not Found)
send @ jquery.min.js:2
ajax @ jquery.min.js:2
w.(anonymous function) @ jquery.min.js:2
getJSON @ jquery.min.js:2
(anonymous) @ water-level-chart.js:59
l @ jquery.min.js:2
c @ jquery.min.js:2
setTimeout (async)
(anonymous) @ jquery.min.js:2
u @ jquery.min.js:2
fireWith @ jquery.min.js:2
fire @ jquery.min.js:2
u @ jquery.min.js:2
fireWith @ jquery.min.js:2
ready @ jquery.min.js:2
_ @ jquery.min.js:2
不确定这意味着什么。
这是我的ajax
$(document).ready(function() {
$('#action-form').submit(function(event) {
event.preventDefault(); // Prevent the form from submitting via the browser
var form = $(this);
$.ajax({
type: form.attr('method'),
url: form.attr('action'),
data: form.serialize()
}).done(function(data) {
// Optionally alert the user of success here...
}).fail(function(data) {
// Optionally alert the user of an error here...
这是我的index.haml
%head
%script{type: "text/javascript", src: url('/javascripts/jquery.min.js')}
%script{type: "text/javascript", src: url('http://code.highcharts.com/highcharts.js')}
%script{type: "text/javascript", src: url('/javascripts/highcharts-more.js')}
%script{type: "text/javascript", src: url('/javascripts/solid-gauge.js')}
%script{type: "text/javascript", src: url('/javascripts/synchronized-charts.js')}
%script{type: "text/javascript", src: url('/javascripts/water-level-chart.js')}
%script{type: "text/javascript", src: url('/javascripts/water-pump.js')}
%link{rel: :stylesheet, type: :"text/css", href: url('/stylesheets/default.css')}
#container
#synchronized
.gauge
#container-speed
.pump-control
%form{method: :post, action: '/take-action', id: 'action-form' }
%input{type: 'hidden', name: 'action', value: 'start', id: 'action_input'}
%span{id: 'pumper', onclick: 'takeAction()'}
start
我从未使用过javascript或jquery。我试图按照这个项目进行https://www.hackster.io/demirhanaydin/waterpi-houseplant-remote-watering-and-monitoring-system-340400#toc-step-1--setup-dynamodb-0,而我在第6步中无法弄明白。