私はajaxを使用してコントローラから変数を取得しています。返されたデータを別の変数にプッシュするまではすべてが素晴らしいです。Javascript変数にはランダムな設定値があります
は、ここで私とデータ[i]が全て正しい値と、完璧で使用して、コード
$(".event_selector").change(function() {
$.ajax({
url: "/get_customer_values",
type: "GET",
async:false,
data: {event_selected: $(".event_selector").val()},
success: function(data){
var customer_values = {};
for (var i in data) {
//This alert has the correct values
alert(i + " " + data[i]);
customer_values[i] = data[i];
}
}
});
for(var i in customer_values) {
//This is the alert that shows all the crazy values
alert("customer_values " + i + " " + customer_values[i]);
}
add_customer_values_to_panel(customer_values)
});
最初のアラートの私の抜粋です。
キー値
クリック機能クリック(){[ネイティブコード]}
プロパティ[オブジェクトHTMLPropertiesCollection]
:customer_valuesハッシュを用いた第2の警告は、次のような設定のように見える値を有しますのonchangeヌルヌルoncanplaythrough
onclickのヌル
れるondblclickヌルヌルも、oncontextmenu
ondragヌル
ondragendヌル
getAttributeNames関数getAttributeNames(){[ネイティブコード]}
のgetAttribute関数のgetAttribute( ){[native code]}
getAttributeNS関数getAttributeNS(){[ネイティブコード]}
これには少なくとも100個の値があります。
var customer_valuesの初期化をajaxのアウトサイトに移動しようとしましたが、動作しません(何も起こらず、最初のアラートはトリガーされません)。
何が起こっていますか?そのデータはどこから来ていますか?ありがとうございました。
あなたは 'customer_values'を宣言しないと、どのようにあなたがそれを初期化しますか? –
'id =" customer_values "'のhtml要素がありますか?唯一の 'customer_values'がAjaxの成功コールバックの中で宣言されていることを考えると、2番目の' for'ループ*はアクセスできませんが、参照エラーを投げるのではなく、html要素のロギングプロパティですよく... – nnnnnn