0

我正在寻找一种方法来使用 RestKit API 从我的网站的下拉菜单中选择一个项目。我搜索了网络,但它没有给我相关的结果。这是下拉菜单的 HTML 代码:

<form class="myProfile" method="POST">
    <div class="myProfile">Which one is your favorite soccer team?
    <select class="team_selection" name="favTeamID" id="favTeamID" onchange="JavaScript:submit()">
<option value="">Select One...</option>
<option value="203">Manchester</option>
<option value="1">Barcelona</option>
<option value="2">Chelsea</option>
</select>

我尝试使用以下代码发布键值“name”和“id”:

[RKClient clientWithBaseURLString:@"http://MyWebsite.com"];

    NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys:
                            @"Barcelona", @"name",
                            @"1", @"id",
                            nil];

    RKRequest *request = [[RKClient sharedClient] post:@"/profile.php" params:params delegate:self];
    [request setUserData:@"selectFavoriteTeam"];

但它不起作用。如果有人可以帮助我,我将不胜感激。

4

1 回答 1

0

我想通了,我必须在 favTeamID 上发布代码:

[RKClient clientWithBaseURLString:@"http://MyWebsite.com"];

    NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys:
                            @"1", @"favTeamID",
                            nil];

    RKRequest *request = [[RKClient sharedClient] post:@"/profile.php" params:params delegate:self];
    [request setUserData:@"selectFavoriteTeam"];
于 2012-09-18T06:12:38.603 回答