Click here to Skip to main content
15,923,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I a asmx webservice I am trying to call using JQuery. I am getting the error undefined .

JavaScript
function WebMethod(fn, paramArray, successFn, errorFn) {

    //----------------------------------------------------------------------+
    // Create list of parameters in the form:                               |
    // {'paramName1':'paramValue1','paramName2':'paramValue2'}              |
    //----------------------------------------------------------------------+
    var paramList = '';
    if (paramArray.length > 0) {
        for (var i = 0; i < paramArray.length; i += 2) {
            if (paramList.length > 0) paramList += ',';
            paramList += '"' + paramArray[i] + '":"' + paramArray[i + 1] + '"';
        }
    }
    paramList = '{' + paramList + '}';
//   url: 'http://service.4dpeeps.com/TSService/ImagesService.asmx' + '/' + fn,
    $.ajax({
        url: '../ImagesService.asmx' + '/' + fn,
        global: false,
        type: "POST",
        dataType: 'json',
        data: paramList ,
        contentType: 'application/json; charset=utf-8',
        success: successFn,
        error: errorFn
    });
    //----------------------------------------------------------------------+
    // Call the WEB method                                                  |
    //----------------------------------------------------------------------+
   // $.ajax({ data: paramList });
}

// xhrFields: {
//            withCredentials: true
//        },
//---------------------------------------------+
// jQuery AJAX Call Succeeded.                 |
//---------------------------------------------+
function AjaxSucceeded(result) {
    alert(result.d);
    var tableView = $find(RgImages).get_masterTableView();
    tableView.set_dataSource(result);
    tableView.dataBind();

}

//------------------------------------------------+
// jQuery AJAX Call FAILED.                       |
//------------------------------------------------+
function AjaxFailed(result) {



    DoSomething(result.d);
}


function DoSomething(msg) {
    // Do something with the response data here.
    //  Expect it to consistently have no .d.
    alert('SERVICE Failed : ' + msg);
}




This is my webservice. It never makes it to the webservice but fails in the javascript

VB
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports TsBusiness.TsBusiness
Imports System.Web.Script.Services

Namespace TSWebServices
    ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
    ' <System.Web.Script.Services.ScriptService()> _
    <System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
    <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    <System.Web.Script.Services.ScriptService()> _
    <ToolboxItem(False)> _
    Public Class ImagesService
        Inherits System.Web.Services.WebService

        Private mImageUpload As Images.Images
    
        <WebMethod(MessageName:="Images by Ids")> _
      <ScriptMethod(UseHttpGet:=True, ResponseFormat:=ResponseFormat.Json)> _
        Public Function GetImageURLs(ByVal id As Integer) As List(Of TsDbAccess.ts_ImagesResult)
            ' mImageUpload = New Images.Images
            Return mImageUpload.GetImages(id)
        End Function
    End Class
End Namespace


any help would be greatly appreciated
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900