0

Im trying to send via ajax a value from a textfield, but don't want to use a form , don't think is needed:

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 );
});

This is the primary function, bellow is the html markup:

<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>

Shouldn't this be enough?

2 Answers 2

2

Try:

var name = $(".teximput").val();
$.ajax({
type: "GET",
url: "ajaxload/icall.php",
data: "numero="+name,
success:function(msg) {
alert( "Data Saved: " + msg );
});

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the tip, actually, the $("#icall") wouldn't work because it's not a div with that atribute, but $(".teximput") worked like a charm. How could i not use jQuery for this, so simple. By the way, the merit is yours, so selected as the right answer ;)
0
document.getElementByName["icall"].value

is incorrect. The function is getElementsByName. Also, Instead of square brakets, use parentheses for function calls:

document.getElementsByName("icall")[0].value

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.