62,046
社区成员
发帖
与我相关
我的任务
分享
var postdata = { Id: "1", Name: "Jim", CreateTime: "1988-09-11" };
$.ajax({
type: "get",
url: "https://tcc.taobao.com/cc/json/mobile_tel_segment.htm",
data: { tel: "180520410" },//postdata
dataType: 'jsonp',
crossDomain: true,
success: function (data, status) {
if (status == "success") {
alert(data);
//$.lrSaveForm(top.$.rootUrl + '/FK_Production/Basic_Model/Clean', { BM_Id: bm_id }, function (res) {
// page.search();
//});
}
}
});
public async void APIPost(string BM_Id, string State)
{
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("BM_Id", BM_Id);
dic.Add("State", State);
var content = new FormUrlEncodedContent(dic);
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:55931/");
var result = await client.PostAsync("ActionApi/UserInfo/UpdateState?BM_Id=" + BM_Id+ "&State="+State, content);
Console.WriteLine("Result:{0}", result);
}
调用:a.APIPost(BM_Id, "已清洗");
apidemo:
public class UserInfoController : ApiController
{
private SqlConnection conn = null;
private SqlCommand cmd = null;
//private SqlDataAdapter adapter = null;
//为了方便,设为全局对象的sql语句
private string sql = null;
private ApiTools tool = new ApiTools();
[HttpPost]
[HttpGet]
public int UpdateState(string BM_Id,string State)
{
sql = "update Basic_Model set BM_State='"+ State + "' where BM_Id='" + BM_Id + "'";
int i=execute(sql);
return i;
}
我是这么写的,调用是成功的能改数据