开发者

How to get a serialized array from a client form to a server using the GM_xmlhttpRequest

I used JQuery.serializeArray() on a form to create an array of objects on a GreaseMonkey application:

[
  {
    name: a
    value: 1
  },
  {
    name: b
    value: 2
  },
  {
    name: c
    value: 3
  },
  {
    name: d
    value: 4
  },
  {
    name: e
    value: 5
  }
]

I need to use GM_xmlh开发者_JAVA百科ttpRequest to serve these fields back to a server side application. What is the best way to return these fields?

Thanks in advance,

D


I think I found the answer...

I need to use

JSON.stringify(obj)

to turn my serialized fields into a json string. Then I should be able to serve that string to the server as one of the data arguments in a GM_xmlhttpRequest POST request.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜