Nestor C
Nestor C

Reputation: 637

Sending multiple data parameters with single quote with jQuery AJAX

i am using ajax jquery method to pass value to server, but my problem is i am using some value with single quote ' and it's give me error ,

ClientManager = "Client's Manager " <== here i am passing value with ' (single quote)


  data: "{projectSoid': '" + ProjectId + "','startDate': '" + StartDate + "','endDate': '" + EndDate + "','clientManager': '" + ClientManager + "'}",

and ajax jquery method, Error give me error :-

Message: Invalid object passed in, ':' or '}' expected. ........

infect i want all fields allows with ' (single quote)

what's the best soulution to passdata as jQuery Ajax Methods's data : {

Upvotes: 2

Views: 1683

Answers (1)

Kevin Bowersox
Kevin Bowersox

Reputation: 94499

Try defining an object literal, instead of concatenating a String.

data: {
        "projectSoid": ProjectId,
        "startDate": StartDate,
        "endDate": EndDate,
        "clientManager": ClientManager
      },
          //other entries

Upvotes: 2

Related Questions