我正在寻找一种方法,通过使用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”进行POST:
[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"];
但它不起作用。如果有人能帮助我,我将不胜感激。
答案 0 :(得分: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"];