Reputation: 386
How can I add a prefix to the payload of a JSON post request. Always prefixed with 'INC-'
Say I have
Incident: 12345
data: JSON.stringify({ incident: $("#incident: _name").val() }),
Returns 12345
What I want
Incident: 12345
data: JSON.stringify({ incident: $("#incident: _name") "INC-" .val() }),
Returns INC-12345
Upvotes: 1
Views: 440
Reputation: 57721
I think it should be written like this.
Where the $("#incident: _name").val()
part uses JQuery to select the element with ID attribute and the .val()
is used to get the value inside the input field. then you can just concatenate INC-
to the selector output string!
data: JSON.stringify({ incident: "INC-"+ $("#incident: _name").val() }),
Upvotes: 2