I need to find a particular data from jquery.here my code.But i don't know what was fault in thisI could not fetch data from jquery.Anyone help me to do this
Aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Products.aspx.cs" Inherits="jQuery1.Products" %>
Name:
Please click to load the products from server:
xml
js
$(document).ready(function() {
$('#loadBtn').click(function() {
$.ajax({
url:'Product_details.xml',
type:'get',
datatype:'xml',
error:function(jqxHR,textstatus,errorThrown){
Console.log('Error:',+errorThrown);},
success:function(xml){
xmlDoc = $.parseXML( xml );
$xml = $( xmlDoc );
if($xml.find("product").length>0&&$.trim("id").length>0)
{
var id = $.trim($("#txtID").val());
var product="Product: Contains('"+id+"')";
if(product.length>0)
{
console.log('AJAX Request is succeded.');
var productsTable = '';
productsTable += '';
';
| Id | Name | Price | Discount | ';
| '+$(xml).find(product).text()+' | ';'+$(xml).find(product).next("name").text()+' | ';'+$(xml).find(product).next("price").text()+' | ';'+$(xml).find(product).next("discount").text()+' | ';
$("#products").append(productsTable);
}
else
{
$("#products").append("No elements found"+product);
}
}
},
});
});
});
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Puneet KankarPosted Jul 24, 2017, 7:46 AM