我正在尝试在我的codeIgniter项目上使用javascript代码.但我没有执行它.我尝试了太多方法来解决它:我调用外部js代码,它没有用.我把它放在我的视图页面中它也不起作用.我认为问题很简单,但我看不出来.你怎么看待这个问题?
view.php
<html>
<?php include("/external/css/style.css"); ?>
<head>
<title>New Customer</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script>
function makeAjaxCall(){
$.ajax({
alert("I'm here"); // I cant see that
type: "post",
url: "http://localhost/codeigniter_2/index.php/homepage/verifyUser",
cache: false,
data: $('#addCust').serialize(),
success: function(json){
try{
var obj = jQuery.parseJSON(json);
alert( obj['STATUS']);
}catch(e) {
alert('Exception while request..');
}
},
error: function(){
alert('Error while request..');
}
});
}
</script>
</head>
<body>
<h1>Customer Add</h1><a href="http://localhost/codeigniter_2/index.php">list</a>
<form name="addCust" method="post" action="insert">
<table border="1">
<tr>
<th>Customer Name:</th>
<td><input type="text" id="custom" name="customerName"/></td>
<tr>
<th>Customer Phone:</th>
<td><input type="text" name="phone"/></td>
<tr> …Run Code Online (Sandbox Code Playgroud) 我正在尝试像任何国家的iban代码进行iban验证.我从stackoverflow获得了一些帮助来构建代码,但我仍有一些问题,我不知道它在哪里.
我总是得到'这不是一个有效的IBAN'错误消息.但有时我尝试将iban代码更正为定义的国家/地区.
有没有人帮助我做这个验证的代码,拜托?
代码在这里:
class BankAccount < ActiveRecord::Base
belongs_to :user
validates :bank_name, presence: true
validate :iban, :valid_iban?, presence: true
private
def valid_iban?
ibans = iban.upcase.scan(/\w/).join
ibans = ibans.gsub(/_/, '')
iban_length = ibans.length
country = ibans.scan(/\A../).join
length_correct_for_country = true
case country
when "IE"
if iban_length == 22
length_correct_for_country = true
else
length_correct_for_country = false
end
when "AL"
if iban_length == 28
length_correct_for_country = true
else
length_correct_for_country = false
end
when "TR"
if iban_length == 26
length_correct_for_country = true
else
length_correct_for_country = …Run Code Online (Sandbox Code Playgroud) 我有一个名为 Record 的模型,属于 Product 模型,
所述price列类型是十六进制的。Rails 已经将其转换为字符串。但我想在我的控制台查询中获取它们。
pluck 的示例代码:
Product.first.records.pluck(:price)
Run Code Online (Sandbox Code Playgroud)
此查询将数组中的值显示为十六进制。有一种方法to_sentences 需要 pluck 值,但对我来说还不够。
问题在collect方法上是一样的:
Product.first.records.collect(&:price)
Run Code Online (Sandbox Code Playgroud)
将我的十六进制数据显示为字符串数组的 pluck 查询是什么,例如:
["45,46","75,42"]
Run Code Online (Sandbox Code Playgroud) ruby ×2
ajax ×1
codeigniter ×1
collect ×1
iban ×1
javascript ×1
jquery ×1
php ×1
pluck ×1
validation ×1