使用jQuery消耗WCF [英] consume WCF USING jquery
本文介绍了使用jQuery消耗WCF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有wcf服务,当我尝试使用jquery调用insert方法时,该方法不起作用:
这是我的代码:
WCF代码
hi to all,
i had make wcf services, what when i try invoke insert method using jquery, it''s not work:
here is my code :
WCF code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Data;
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService" in both code and config file together.
[ServiceContract]
public interface IService
{
[OperationContract]
void addnewcategory(string name, int price, int type);
[OperationContract]
DataTable selectcategory();
[OperationContract]
void updatecategory(string Name, int price, int type, int id);
[OperationContract]
Boolean deletecategory(int id);
}
service.cs代码:
service.cs code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Bal;
using System.Data;
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service" in code, svc and config file together.
public class Service : IService
{
public void addnewcategory(string name, int price, int type)
{
Bal.insertcategory obbalinsertcategory = new Bal.insertcategory();
obbalinsertcategory.inserttocategory(name, price, type);
}
public DataTable selectcategory()
{
Bal.insertcategory obbalinsertcategory = new Bal.insertcategory();
return obbalinsertcategory.selectcategory();
}
public void updatecategory(string Name, int price, int type, int id)
{
Bal.insertcategory obbalinsertcategory = new Bal.insertcategory();
obbalinsertcategory.updatecategroy(Name, price, type, id);
}
public Boolean deletecategory(int id)
{
Bal.insertcategory obdelte = new Bal.insertcategory();
return obdelte.deletecategory(id);
}
}
web.config
web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="Con" connectionString="Data Source=.;Initial Catalog=market;User ID=sa;Password=market;Trusted_Connection=false;Pooling=false"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
</configuration>
aspx代码:
您好,需要从Webserice调用addnewcategory的jquery方法,请帮助
aspx code:
hi need here jquery method that invoke addnewcategory from webserice please help
推荐答案
检查以下CP中的文章:
使用jQuery调用WCF服务 [调用在JQuery中暴露有不同绑定的WCF服务 [ ^ ]
其他文章:
calling-wcf-services-using-jquery [ ^ ]
Check following articles in CP:
Calling WCF Services using jQuery[^]
Calling WCF service exposed with different bindings in JQuery[^]
Other articles:
calling-wcf-services-using-jquery[^]
这篇关于使用jQuery消耗WCF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文