Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling ASP.NET function using JQuery $.AJAX call

My page contains the following code in the function called when a button is clicked:

$.ajax({   
    type: "POST",   
    url: "ProviderPortal.aspx/ppTransferToProvider",   
    data: "{ICA_Key:'" + ICAKey + "', PROV_Key:'" + Provider + "'}",   
    contentType: "application/json; charset=utf-8",
    async: true,           
    cache: false,    
    dataType: "json",   
    success: function(msg) {     
        alert(msg) 
    } 
}); 

This code is modeled after the selected answer to Calling an ASP.NET server side method via jQuery

However, I'm not sure if the ASP.NET (VB, Net 2.0) function signature

<WebMethod()> _
Public Shared Function ppTransferToProvider( _
    ByVal ICA_Key As String, _ 
    ByVal Prov_Key as String) As String

on the page will receive the data as distinct parameters, or as a string that will have to be parsed for these values. Also, I can't determine if the call is even being made correctly; it seems that a breakpoint in the function itself is never getting hit, so I can't see it for myself.

a) Are parameters passed as just a big string, or are they correctly passed to my function with two parameters? b) How can I trace the execution of the ASP.NET function? Or is it possible to trace, given that it's shared?

like image 795
taserian Avatar asked Dec 28 '22 11:12

taserian


1 Answers

The problem is you're passing a string while you're service is expecting a set of objects. Try the following instead

data: {ICA_Key: ICAKey, PROV_Key: Provider },
like image 51
JaredPar Avatar answered Jan 08 '23 09:01

JaredPar