jQuery v1.7.2
I have this funcion that is giving me the following error while executing :
Uncaught TypeError: Illegal invocation
Here's the function :
$('form[name="twp-tool-distance-form"]').on('submit', function(e) {
e.preventDefault();
var from = $('form[name="twp-tool-distance-form"] input[name="from"]');
var to = $('form[name="twp-tool-distance-form"] input[name="to"]');
var unit = $('form[name="twp-tool-distance-form"] input[name="unit"]');
var speed = game.unit.speed($(unit).val());
if (!/^d{3}|d{3}$/.test($(from).val()))
{
$(from).css('border-color', 'red');
return false;
}
if (!/^d{3}|d{3}$/.test($(to).val()))
{
$(to).css('border-color', 'red');
return false;
}
var data = {
from : from,
to : to,
speed : speed
};
$.ajax({
url : base_url+'index.php',
type: 'POST',
dataType: 'json',
data: data,
cache : false
}).done(function(response) {
alert(response);
});
return false;
});
If I remove data
from ajax call, it works .. any suggestions?
Thanks!
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…