Avatar of Camillia
Camillia
Flag for United States of America asked on

Saving Jquery to database - web service

If you look at the related question,,,,i need to save firstname, last name to the databse. JQuery is being used. My coworker gave me the solution below but I dont know how to pass the Javascript array to the webservice...

This is the JQuery http://jsfiddle.net/mplungjan/zHQ2d/

His solution is below:
… you should just use an AJAX POST.

I would create a lite Person Object in javascript and match up the definitions with the server side – like this:
[ScriptService]
public class PersonService : WebService
{
  [WebMethod]
  public void SavePerson(Person PersonToSave)
  {
    // (assuming Person has a Save() method).
    PersonToSave.Save();
  }
}

You’d pass in an array of Person in the example above

Open in new window

jQueryASP.NETAJAX

Avatar of undefined
Last Comment
leakim971

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
leakim971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Camillia

ASKER
let me try. Been stuck on this for a week now.
leakim971

"fn" and "ln" are the members of PersonToSave class
Camillia

ASKER
hmm...not sure what that means... so this these are 2 lines:
var fn = $(this).val();
var ln = $("#"+ln_ID).val();

So, PersonToSave should have "fn" and "ln" doing what?? as parms?
Your help has saved me hundreds of hours of internet surfing.
fblack61
leakim971

I was talking about the C# PersonToSave class, server side
Camillia

ASKER
yes, in C# PersonToSave...what should "fn" and "In" be??
leakim971

first name and last name (both string)
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.