这是我在aspx文件中的代码......
function updateuserstatus(arg){ //../images/approved.jpg" :" ../ images / rejected.jpg"
var datauserid = $(arg).attr('data-userid'); var curStatus = $(arg).attr('data-status'); var upmstatus = (curStatus.toString().toLowerCase() == 'false' ? true : false); $.ajax({ type: "POST", url: "Login.aspx/updatematerialstat", data: '{status: "' + upmstatus + '", id:"' + datauserid + '" }', contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { if (msg.d) { var srcd = upmstatus ? "../admin/images/icn_alert_success.png" :
" ../管理员/图像/ icn_alert_error.png&#34 ;; $("#img" + datauserid +"")。attr(" src",srcd); $(arg).attr(' data-status',upmstatus); } }, 失败:功能(响应){ 警报(response.d); } }); }
<asp:GridView ID="GridView1" runat="server" BackColor="#CCCCCC" BorderColor="#999999" BorderWidth="3px" CellPadding="4" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowDeleting="GridView1_RowDeleting" BorderStyle="Solid" OnRowCommand="GridView1_RowCommand" CellSpacing="2" ForeColor="Black" Height="100px" Width="602px" AutoGenerateColumns="False" AutoGenerateDeleteButton="True" onselectedindexchanged="GridView1_SelectedIndexChanged"> <Columns> <%--<asp:TemplateField HeaderText="IsActive"> <ItemTemplate> <asp:CheckBox ID="chkisactive" runat="server" Checked='<%# Eval("Isactive") %>' /> </ItemTemplate> <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> </asp:TemplateField>--%> <asp:TemplateField HeaderText="Edit"> <ItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%# Eval("ID") %>' CommandName="Update">Update</asp:LinkButton> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="FName"> <EditItemTemplate> <asp:Label ID="lbleditid" runat="server" Text='<%# Eval("ID") %>' Visible="False"></asp:Label> <asp:Label ID="lblfname" runat="server" Text='<%# Eval("Firstname") %>'></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="lblfnameitem" runat="server" Text='<%# Eval("Firstname") %>'></asp:Label> <asp:Label ID="lbluserid" runat="server" Text='<%# Eval("ID") %>' Visible="False"></asp:Label> </ItemTemplate> <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> </asp:TemplateField> <asp:TemplateField HeaderText="LName"> <EditItemTemplate> <asp:Label ID="lbllastname" runat="server" Text='<%# Eval("Lastname") %>'></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="lbllnameitem" runat="server" Text='<%# Eval("Lastname") %>'></asp:Label> </ItemTemplate> <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> </asp:TemplateField> <asp:TemplateField HeaderText="Usertype"> <ItemTemplate> <asp:Label ID="lblusertype" runat="server" Text='<%# Eval("Usertype") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Email"> <EditItemTemplate> <asp:Label ID="lblemailid" runat="server" Text='<%# Eval("EmailID") %>'></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="lblemailitem" runat="server" Text='<%# Eval("EmailID") %>'></asp:Label> </ItemTemplate> <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> </asp:TemplateField> <asp:TemplateField HeaderText="City"> <EditItemTemplate> <asp:Label ID="lblcity" runat="server" Text='<%# Eval("City") %>'></asp:Label> </EditItemTemplate> <ItemTemplate> <asp:Label ID="lblcityitem" runat="server" Text='<%# Eval("City") %>'></asp:Label> </ItemTemplate> <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> </asp:TemplateField> <asp:TemplateField HeaderText="State"> <ItemTemplate> <asp:Label ID="lblstate" runat="server" Text='<%# Eval("State") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Address"> <ItemTemplate> <asp:Label ID="lbladdress" runat="server" Text='<%# Eval("Address") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Phone"> <ItemTemplate> <asp:Label ID="lblphone" runat="server" Text='<%# Eval("Phone") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Approve"> <ItemTemplate> <a href="javascript:;" data-status="<%#Eval("Isactive") %>" data-userid="<%#Eval("ID") %>" onclick="updateuserstatus(this);"> <img id='img<%#Eval("ID") %>' src='<%# Convert.ToBoolean(Eval("Isactive")) ?
&#34; ../管理员/图像/ icn_alert_success.png&#34; : &#34; ../管理员/图像/ icn_alert_error.png&#34; %GT;&#39; 高度=&#34; 20像素&#34;宽度=&#34; 20像素&#34; /&GT;
&#39;&GT;
以下是网络方法......
[的WebMethod] public static bool updatematerialstat(bool status,int id) { bool res = false; 尝试 { user.Operation obj = new user.Operation(); if(obj.ustatus(status,id)) {res = true; } } catch(Exception ex) { 抛出前 } 返回资源; }
现在在浏览器中出现以下错误...
&#34; ReferenceError:$未定义&#34;
任何解决方案.... ???
答案 0 :(得分:0)
将此行放在页面的“head”部分,您可以在其中定义对css文件和.js文件的引用。:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
“ReferenceError:$未定义”当您错过提供对jQuery min文件的引用时会出现错误。