我正在完成一项学校作业,其中我们需要使用 ruby cgi 脚本从 html 表单接收信息,并使用 fadeIn() jQuery 方法来显示它。
我的脚本看起来像:
#!/usr/local/bin/ruby -w
require 'cgi'
cgi = CGI.new('html4')
cgi.out{
cgi.html{
cgi.head{cgi.title{"This is a test"}+ cgi.style{"p{color = red;}"}} +
cgi.body{cgi.p{"Try this " + cgi['ffname'] + ", did that work?"}}
}
}
这实际上是我的一些测试代码,以确保服务器按照我想象的方式工作。
当我尝试使用类似的东西时:
puts "<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>"
服务器拒绝运行它,所以我猜这是不允许的。
我还是 ruby cgi 类(class)的初学者。
如何使用这些 cgi 方法引用 jquery 库?
最佳答案
与向客户端发送 html 的方式类似,您将向客户端发送一些 javascript 代码。此 JavaScript 代码将包含对 jQuery 函数的调用。
关于javascript - 如何在 ruby 中使用 cgi 方法引用 jquery 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40569568/