我尝试通过ajax从文本字段发送值,但不想使用表单,不要认为是需要的:
name = document.getElementByName["icall"].value;
alert( "Data Saved: " + name );
$.ajax({
type: "GET",
url: "ajaxload/icall.php",
data: "numero="+name
}).done(function( msg ) {
alert( "Data Saved: " + msg );
});
这是主要功能,下面是html标记:
<div class="conteudo">
<span class="numero">O seu numero:</span><input type="text" name="icall" class="teximput" size="30"></input>
<p><span class="avisome">Precisa de ajuda com algo? Nos ligamos consigo na proxima hora!</span></p>
<a href="javascript:void(0)" onclick="ligarme();"><span class="botaoliga"></span></a>
</div>
这不够吗?
答案 0 :(得分:2)
尝试:
var name = $(".teximput").val(); $.ajax({ type: "GET", url: "ajaxload/icall.php", data: "numero="+name, success:function(msg) { alert( "Data Saved: " + msg ); });
答案 1 :(得分:0)
document.getElementByName["icall"].value
不正确。该函数是getElement s ByName。此外,使用括号进行函数调用,而不是方形的brakets:
document.getElementsByName("icall")[0].value