Wat u want to do exactly?, wats ur server's response type?, u dont really need to worry about Searlization if u r using Jquery.
If server's response is an XML u need to set the option 'dataType' to 'XML' in ur ajax call and have the success handler as below in which u could use the standard ways to access data in it
success: function(XMLObj) {
//XMLObj is an XMLDoc and u could use standard ways to access data in it
}
If its JSON then u need to set the optionto 'JSON' in ur ajax call and have the success handler as below in which u could access the returned data as normal javascript object
success: function(jsonData){
jsonData.FieldName1 // access just like normal javascrip object, field names should be as in DTO
}
RahulSharma4...
Member
7 Points
6 Posts
How to Deserilize in jquery ?
Feb 29, 2012 03:38 PM|LINK
Hello freinds i m new to jquery so i do not know how to Deserialize in jquery.its urgent pls reply.
Ramesh T
Contributor
5091 Points
822 Posts
Re: How to Deserilize in jquery ?
Feb 29, 2012 04:28 PM|LINK
Hello Mate,
Wat u want to do exactly?, wats ur server's response type?, u dont really need to worry about Searlization if u r using Jquery.
If server's response is an XML u need to set the option 'dataType' to 'XML' in ur ajax call and have the success handler as below in which u could use the standard ways to access data in it
success: function(XMLObj) { //XMLObj is an XMLDoc and u could use standard ways to access data in it }If its JSON then u need to set the optionto 'JSON' in ur ajax call and have the success handler as below in which u could access the returned data as normal javascript object
success: function(jsonData){ jsonData.FieldName1 // access just like normal javascrip object, field names should be as in DTO }Cheers,
R
RahulSharma4...
Member
7 Points
6 Posts
Re: How to Deserilize in jquery ?
Mar 01, 2012 06:10 AM|LINK
can anybody tell me whats error in it
<script type="text/javascript">
$(document).ready(function () {
$('#txtSearch').keyup(function () {
var firstdata = $("#txtSearch").val();
$.ajax({
url: "Autocompletewithdata.aspx",
type: "POST",
data: firstdata,
dataType: "json",
success: function (data) {
var result = new Array();
//result = eval('(' + $data + ')');
alert(data);
alert(result[0]);
alert(result[1]);
},
error: function (err) {
alert(err);
}
})
})
$("#txtSearch").autocomplete({
source: result
});
});
</script>
asteranup
All-Star
30184 Points
4906 Posts
Re: How to Deserilize in jquery ?
Mar 01, 2012 06:28 AM|LINK
Hi,
Try this post-
http://delicious.com/anupdg/autocomplete+webservice
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
RahulSharma4...
Member
7 Points
6 Posts
Re: How to Deserilize in jquery ?
Mar 01, 2012 08:32 AM|LINK
I have a problem how to return data when i receive this data
["aa ","aaabb ","abc ","abbc "] and my code is <script type="text/javascript"> $(document).ready(function () { $('#txtSearch').keyup(function () { var firstdata = $("#txtSearch").val(); $.ajax({ url: "Autocompletewithdata.aspx", type: "POST", data: firstdata, dataType: "json", success: function (data) { var result = new Array(); result = eval('(' + $data + ')'); alert(data); alert(result[0]); alert(result[1]); }, error: function (err) { alert(err); } }) }) $("#txtSearch").autocomplete({ source: result }); }); </script>asteranup
All-Star
30184 Points
4906 Posts
Re: How to Deserilize in jquery ?
Mar 01, 2012 09:15 AM|LINK
Hi,
Use this post-
http://forums.asp.net/t/1647220.aspx
In this post if you are returning a single array then replace the success method with-
success: function(data) { response($.map(data.d, function(item) { return { label: item, value: item } })) },There are manu more post here-
http://delicious.com/anupdg/autocomplete
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog