javascript - jQuery .post or .get pass dynamic parameters -


the common way send request server is

$.get('link/to/send', {    param1: "value1",    param2: "value2" }, function(result) {    // ... etc }); 

now if want send dynamic parameter names, can jquery support that? (i.e. need write generic code can specify parameter names @ runtime)

this not jquery dependent, it's vanilla javascript.

you should this:

var objtosend = {}; objtosend["param1"] = "value1"; objtosend["param2"] = "value2";  $.get('link/to/send', objtosend, function(result) {     // ... etc }); 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

php - How do you embed a video into a custom theme on WordPress? -