What is the best way to call a .net webservice using jquery?

前端 未结 6 1373
粉色の甜心
粉色の甜心 2020-12-17 04:19

I\'d like to call a .net webservice from another domain using only jquery.

What is the best way to do this? and are there any configuration changes I need to be awar

6条回答
  •  一向
    一向 (楼主)
    2020-12-17 05:13

    Here is an example:

    $.post("CodersWS.asmx/DeleteBook", { id_book: parseInt(currBookID, 10) }, function(res) {
    ///do something with returned data: res
    });
    

    In the above example, I am calling a web service named CodersWS.asmx, and the WebMethod inside it called DeleteBook...I am also passing a parameter called id_book.

    Also don't forget to add this snippet to your web.config, or else you wouldn't be able to access the web-service this way:

    
        
            
                
                
            
        
    
    

提交回复
热议问题