简体   繁体   中英

AJAX request in jQuery get function, variable issues

I'm struggling with a jQuery Ajax call. Please help!

var email = patrick@patrick.com;
var password = patrick;

$.get("server.php", {option:"signup", email:"email", password:"password}, function(req){
alter (req);}

So I'm sending two variables to the server, email and password. But I'm sending the signup option in text. How do I send the jQuery variables? The text seems to be working but not the email and password variables. Thanks so much!

删除passwordemail周围的引号。

{option:"signup", email:email, password:password}

how do i send the jquery variables?

There are no "jquery variables". The language is called JavaScript.

{option:"signup", email:"email", password:"password"}

so i'm sending two variables to the server, email and password

No, you send the 3 string literals "signup" , "email" and "password" to the server. To use the variables you declared above, use their names without quotes.

var email = patrick@patrick.com; var password = patrick;

Don't forget the quotes here, when assigning strings to the variables!

var email = "patrick@patrick.com";
var password = "patrick";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM