Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
the below code im using in my solution, but when i pass 'data' parameter in ajax calling, im getting the error but without 'data' parameter it's working fine.

can anyone tell me whats wrong with this.quick response appreciated.


var strInput="";
var strSearchType=$('#ddnSearchType').val();

strInput = strInput +"'strSearch':'"+strSearchType+"'";

disableButtons();

//Clear previous results
$("table#tblInfo tbody tr").remove();

//Ajax Call to JSON
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: 'widgetJosn.asmx/PerformSearch',
data: "{"+strInput+"}",
dataType: "JSON",
success: parseData,
error: AjaxFailed
});
Posted
Updated 16-Feb-12 21:57pm
v3

1 solution

Hi,

you have missed the Parameter name that was used in your <b>PerformSearch</b> function:

if the PerformSearch looks like

Public static string PerformSearch(string Data)
{
//all your code
}

then use the ajax call like:

$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: 'widgetJosn.asmx/PerformSearch',
data: "{'Data':'"+strInput+"'}",
dataType: "JSON",
success: parseData,
error: AjaxFailed
});

hope this will help.
 
Share this answer
 
Comments
Sanjeev Alamuri 17-Feb-12 4:11am    
strInput = strInput +"'strSearch':'"+strSearchType+"'";

this is the my input to webservice.

Public static string PerformSearch(string strInput )
{
//all your code
}
tanweer 17-Feb-12 4:16am    
ok, then your ajax call should looks like:

$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: 'widgetJosn.asmx/PerformSearch',
data: "{'strInput':'"+strInput+"'}",
dataType: "JSON",
success: parseData,
error: AjaxFailed
});

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900