0

It's a silly question, but how can i pass multiple variables through ajax into php? I tried this but doesn't quite suits my needs:

function modifica(estado){
    $.ajax({
    type: "GET",
    datatype: "html",
    url: 'icallverifica.php',
    data: "verifica=1$other=4&gethis="+alerta,
    success: function(data) {
        alert(data);
    }
    });
}

EDIT:

Probably it's this:

data: {
    verifica : "xxx",
    numero : "yyy"
}

But i'll wait for the gurus to help

2
  • 1
    perhaps because you're using a $ instead of an & in your querystring? Commented Dec 7, 2011 at 0:57
  • The second code snipet is the most flexible way of doing it. Why, are you having trouble with it? Commented Dec 7, 2011 at 0:57

3 Answers 3

2

after the page add a question mark(?) and then name=value pairs followed by ampersand(&) after each value

function modifica(estado){
    var action1 = "some text";
    var action2 = 2; // <-- numeric value
    var action3 = "some other text";
    $.ajax({
    type: "GET",
    datatype: "html",
    url: 'icallverifica.php?action1=' + escape( action1 ) + '&action2=' + escape( action2 ) + '&action3=' + escape(action3),
    data: "verifica=1$other=4&gethis="+alerta,
    success: function(data) {
        alert(data);
    }
    });
}
Sign up to request clarification or add additional context in comments.

1 Comment

Although i didn't went this way, for caring about security, i will select as the best answer. Thanks very much.
1

For a get request you can append params to your url 'icallverifica.php?verifica=1&other=4&gethis='+alerta

Comments

1

Like this:url: "data1="+ dataVar1 +"&data2="+ dataVar2 ... etc

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.