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
Post a Comment