Muhafil Saiyed Muhafil Saiyed - 3 months ago 45
Ajax Question

$.parseXML is not a function



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ReviewPage.aspx.cs" Inherits="ReviewPage" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">
<title>AutoComplete Box with jQuery</title>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="Content/themes/AjaxJquery.css" rel="stylesheet" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>

<script src="Scripts/AjaxDataCall.js"></script>
<script type="text/javascript">
$(function () {
Getusers(1);
});
$(".Pager .page").live("click", function () {
GetCustomers(parseInt($(this).attr('page')));
});
function Getusers(pageIndex) {
$.ajax({
type: "POST",
url: "ReviewPage.aspx/Getusers",
data: '{pageIndex: ' + pageIndex + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
}

function OnSuccess(response) {

var xmlDoc = $.parseXML(response.d);
// var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var Users = xml.find("Users");
var row = $("[id*=gvCustomers] tr:last-child").clone(true);
$("[id*=gvCustomers] tr").not($("[id*=gvCustomers] tr:first-child")).remove();
$.each(Users, function () {
var user = $(this);
$("td", row).eq(0).html($(this).find("Id").text());
$("td", row).eq(1).html($(this).find("Rating").text());
$("td", row).eq(2).html($(this).find("Topic").text());
$("[id*=gvCustomers]").append(row);
row = $("[id*=gvCustomers] tr:last-child").clone(true);
});
var pager = xml.find("Pager");
$(".Pager").ASPSnippets_Pager({
ActiveCssClass: "current",
PagerCssClass: "pager",
PageIndex: parseInt(pager.find("PageIndex").text()),
PageSize: parseInt(pager.find("PageSize").text()),
RecordCount: parseInt(pager.find("RecordCount").text())
});
};
</script>
</head>
<body>
<form id="form1" runat="server">
<div class="demo">
<div class="ui-widget">
<asp:Label ID="lblusername" runat="server" Text="Search:"></asp:Label>

<asp:TextBox ID="txtSearch" runat="server" CssClass="autosuggest" onblur="sync()"></asp:TextBox>



</div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>


<%-- <asp:Rating ID="Rating1" runat="server" StarCssClass="blankstar"
WaitingStarCssClass="waitingstar" FilledStarCssClass="shiningstar"
EmptyStarCssClass="blankstar">
</asp:Rating>--%>
<%--<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>,
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> --%>
<span class="rating">
<input type="radio" class="rating-input"
id="Radio1" name="rating-input-1" value="5" />
<label for="rating-input-1-5" class="rating-star"></label>
<input type="radio" class="rating-input"
id="Radio2" name="rating-input-1" value="4" />
<label for="rating-input-1-4" class="rating-star"></label>
<input type="radio" class="rating-input"
id="Radio3" name="rating-input-1" value="3" />
<label for="rating-input-1-3" class="rating-star"></label>
<input type="radio" class="rating-input"
id="Radio4" name="rating-input-1" value="2" />
<label for="rating-input-1-2" class="rating-star"></label>
<input type="radio" class="rating-input"
id="Radio5" name="rating-input-1" value="1" />
<label for="rating-input-1-1" class="rating-star"></label>
</span>

<div id="dummyconnent">
Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content<br />
Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content<br />
Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content<br />
Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content<br />
Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content<br />
Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content<br />
Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content Dummy Content<br />
</div>



</div>

<div>

<table style="border-spacing: 10px; border: groove;" border="0">

<tr style="border-bottom: 0px;">
<td style="padding: 10px; border-bottom: none;">[!] REVIEW!</td>
</tr>
<tr>
<td>Topic:
<asp:Label ID="lblTopic" runat="server" Text="Topic"></asp:Label>
<br />
<span class="rating">
<input type="radio" class="rating-input"
id="rating-input-1-5" name="rating-input-1" value="5" />
<label for="rating-input-1-5" class="rating-star"></label>
<input type="radio" class="rating-input"
id="rating-input-1-4" name="rating-input-1" value="4" />
<label for="rating-input-1-4" class="rating-star"></label>
<input type="radio" class="rating-input"
id="rating-input-1-3" name="rating-input-1" value="3" />
<label for="rating-input-1-3" class="rating-star"></label>
<input type="radio" class="rating-input"
id="rating-input-1-2" name="rating-input-1" value="2" />
<label for="rating-input-1-2" class="rating-star"></label>
<input type="radio" class="rating-input"
id="rating-input-1-1" name="rating-input-1" value="1" />
<label for="rating-input-1-1" class="rating-star"></label>
</span>
</td>
</tr>
<tr>
<td>
<textarea id="txtcomment" cols="20" rows="2" style="resize: none;"></textarea><br />
<br />
<input type="button" id="btnsave" value="save" />
</td>
</tr>
<tr>
<td style="display: inline-block; border-bottom: groove; width: 100%;">All reviews
</td>
</tr>
<tr>
<td>
<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false" RowStyle-BackColor="#A1DCF2"
HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White">
<Columns>
<asp:BoundField ItemStyle-Width="150px" DataField="Id" HeaderText="ID" />
<asp:BoundField ItemStyle-Width="150px" DataField="Rating" HeaderText="Name" />
<asp:BoundField ItemStyle-Width="150px" DataField="Topic" HeaderText="Rating" />
</Columns>
</asp:GridView>
<br />
<div class="Pager"></div>

<%--<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder></div>--%>
</td>
</tr>
</table>

</div>


</form>
</body>
</html>





there is errors shows while i do inspect element in web browser due to this error i cant get my output. i am binding database table in gridview format using asp.net jquery ajax call

for reference i used this website
http://www.aspsnippets.com/Articles/Retrieve-data-from-Database-and-display-on-page-using-jQuery-AJAX-in-ASPNet.aspx


error Detail :- Uncaught TypeError: $.parseXML is not a function


and error in this line

var xmlDoc = $.parseXML(response.d);


here is code





<!-- begin snippet: js hide: false console: true babel: false -->






Answer

Thanks Guys ! i Got my Answer I just replace this

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

with this link

<script type="text/ecmascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>