这些链接:
" How to modify an HTML Select when the name is an array using Javascript"
和 " How to pass an array from HTML to Javascript?"
如果我有2个或更多不同名称的选择标签,会使我失望,如果:
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strconv"
)
type SteamAPI struct {
APIKey string
}
type GetAppNews struct {
AppNews struct {
AppId int `json:"appid"`
NewsItems []struct {
Gid int `json:"gid"`
Title string `json:"title"`
Url string `json:"url"`
IsExternalUrl bool `json:"is_external_url"`
Author string `json:"author"`
Contents string `json:"contents"`
Feedlabel string `json:"feedlabel"`
Date int `json:"date"`
} `json:"newsitems"`
} `json:"appnews"`
}
type JsonResponse map[string]GetAppNews
func (s SteamAPI) GetNewsForApp(appid, count, maxlength int) error {
sAppid := strconv.Itoa(appid)
sCount := strconv.Itoa(count)
sMaxlength := strconv.Itoa(maxlength)
resp, err := http.Get("http://api.steampowered.com/ISteamNews/GetNewsForApp/v0002/?appid=" + sAppid + "&count=" + sCount + "&maxlength=" + sMaxlength + "&format=json")
if err != nil {
return err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
var jsonReturn JsonResponse
json.Unmarshal(body, &jsonReturn)
fmt.Println(jsonReturn)
return nil
}
func main() {
Tester := SteamAPI{""}
Tester.GetNewsForApp(440, 3, 300)
}
答案 0 :(得分:1)
您可以使用$("form").serialize()
发布表单中的所有值。
答案 1 :(得分:0)
如果您需要逐个获取值,您也可以使用此示例。
var category_id = $('#category').val()
var form_data = { category : category_id };
data : form_data,
现在,您可以在需要的地方获取类别值。