Later in a humble station to find a post, a person's a suggestion to remind me.
My original code was written like this:
Error code
Copy Code code as follows:
$.ajax ({
Type: "Post",
URL: "_service.asmx/getdatafromatable",
Data: "{tablename:temp}",
DataType: "XML"
...
WS is written in this way:
WebService
Copy Code code as follows:
[WebMethod]
Public DataSet getdatafromatable (string tablename)
{
DataSet ds = new DataSet ();
Using (SqlConnection con=new SqlConnection (ConnectionString))
{
Con. Open ();
SqlCommand cmd = new SqlCommand ();
Cmd. Connection = con;
Cmd.commandtext = string. Format ("select * from {0}", tablename);
SqlDataAdapter da = new SqlDataAdapter (cmd);
Da. Fill (DS);
}
return DS;
}
[Code]
Online search, all said that if the WS without parameters, with the above data: "{}" is not wrong, but there are parameters such a pass will be an error.
It's simple, it's just a little bit of a change to make.
Correct code
[Code]
$.ajax ({
Type: "Post",
URL: "_service.asmx/getdatafromatable",
Data: {tablename:temp},
DataType: "XML",
...
This is a trivial little detail.
What I want to say is that some people, whether they are cattle or novice, do not blindly reprint other people's things.
Please reprint some of the correct.