How to pass a variable using post method using jquery.load ()

I want to pass variables name, emailin the event .load().

var email = $('#reg-email').val();
var name = $('#reg-name').val();
$("#user-detail").load("proc/reg-step2.php",{ "name": "name" , "email": "email" }, function() {
    $("#ajaxLoader2").remove();
});

What should be the syntax for this section to pass a variable instead of the jst lines I wrote here { "name": "name" , "email": "email" }??

+3
source share
2 answers

You can use a variable instead of a literal: { "name": name, "email": email }

+7
source

In object literature, you can use quotation marks around property names, but you should not use them around variable names that you use in values:

{ "name": name, "email": email }

You can also write an object literal without quotes around property names:

{ name: name, email: email }

You can also mix names and values ​​assigned with quotes and without quotes, as needed:

{ "name": name, email: email }

, name+email, :

{ "name+email": name + ', ' + email }
+1

All Articles