By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,741 Members | 2,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,741 IT Pros & Developers. It's quick & easy.

ajax JQuery - multiple data parameters

P: 77
hello, i have this function..

Expand|Select|Wrap|Line Numbers
  1. function getAllInfoCab()
  2. {
  3.     var slmckdcoy = $("#companyCode").val();
  4.     var slmckdcab = $("#branchCode").val();
  5.     alert(slmckdcoy);
  6.     alert(slmckdcab);
  7.     $.aja{
  8.            url: "getAllInfoCab",
  9.            global: false,
  10.            type: "POST",
  11.            async: false,
  12.            dataType: "html",
  13.            data: "companyCode="+ slmckdcoy,
  14.            success: function (response) {
  15.                        var dynamic_options = $("*").inde $('.dynamic')[0] );                   
  16.                        if ( dynamic_options != (-1)) $(".dynamic").remove();
  17.                     $("#salesmanCode").append(response);
  18.                     $(".first").attr({selected: ' selected'});
  19.                    }
  20.           });
  21.  
you see this below script from the function

data: "companyCode="+ slmckdcoy

that is just one data companyCode that throw through the controller, the question is can i add another data (branchCode) to the data property of ajax??

so, beside companyCode, i want to add branchCode also to the data property.
any idea??

thanks
Oct 22 '08 #1
Share this Question
Share on Google+
4 Replies


acoder
Expert Mod 15k+
P: 16,027
maminx, as a full member now and having received gentle nudges and warnings in past on this very issue, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question). This is your final warning. Any more infringements will lead to a temporary ban which I'm sure you'd like to avoid.

Please use the [code] tags in future.

Moderator.
Oct 22 '08 #2

acoder
Expert Mod 15k+
P: 16,027
you see this below script from the function

data: "companyCode="+ slmckdcoy

that is just one data companyCode that throw through the controller, the question is can i add another data (branchCode) to the data property of ajax??
Use the & as you would in a normal GET request. See example.
Oct 22 '08 #3

P: 77
Use the & as you would in a normal GET request. See example.

so sorry for inconvenient of using the tag...thanks moderator for the warning...

thanks also for the solving..i've solved the problem with this below

data: "companyCode="+ slmckdcoy +"&branchCode="+ slmckdcab,

so it is passing two object (companyCode and branchCode)

thanks a lot..

regards,
maminx
Oct 22 '08 #4

acoder
Expert Mod 15k+
P: 16,027
No problem. Glad to help.

PS. I haven't checked if jQuery does this automatically, but if not wrap values/variables in encodeURIComponent().
Oct 22 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.