我正在创建一个网站,我是PHP的新手.
是否更好的是.html页面按钮Onclick
将调用Javascript,它将链接到与数据库通信的PHP页面然后返回到.html页面?在我看来,这将使PHP成为一种背景语言,你永远不会在URL中看到.php页面.
或者更好地制作我的所有页面.php,以便html和PHP代码可以在同一页面中工作?只是好奇,因为我没有注意到大量的.php网址
我一直在网上搜索几个小时试图使用JQUERY $ .ajax将参数传递给我的代码.我尝试了很多不同的东西,但没有任何效果.当我没有传递任何参数并将vb.net函数设置为不接收参数时,函数将被调用.但是一旦我尝试添加参数,函数永远不会被调用.
客户端:
$("#<%=saveResource2.clientID %>").click(function() {
var parDesc = $("#<%=ddlPDesc.clientID %> option:selected").text();
$("#<%=Button1.clientID %>").click();
$.ajax({
type: "POST",
url: "Projects.aspx/btnSaveResource",
data: JSON.stringify({Desc: parDesc}),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
$("#<%=lblPerson.clientID %>").text(msg);
// Do something interesting here.
}
});
});
Run Code Online (Sandbox Code Playgroud)
服务器端:
Run Code Online (Sandbox Code Playgroud)<WebMethod()> _ <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _ Public Shared Function btnSaveResource(ByVal parDesc As String) As String Dim d As String = parDesc Return d + "test" End Function
我已阅读了不少帖子,但没有人回答这个问题.我创建了一个填充播放器名称列表的tableview.当用户点击名称时,我希望单元格的背景颜色变为红色,黄色或绿色,具体取决于它们在循环中的位置.我不是要改变selectionStyle颜色.背景颜色的改变将表明每个玩家在游戏中接收的问题有多难.这就是我到目前为止所尝试的.当我调试时,我可以看到didSelectRowAtIndexPath被击中,但没有任何变化.有任何想法吗?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Player Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.backgroundColor = [UIColor greenColor];
UILabel *playerName = (UILabel *)[cell viewWithTag:PLAYER_NAME];
playerName.backgroundColor = [UIColor redColor];
}
Run Code Online (Sandbox Code Playgroud)