开发者

can you return a string[] from ASMX to JQuery AJAX?

开发者 https://www.devze.com 2022-12-10 00:47 出处:网络
Here\'s my web method [WebMethod(EnableSession = true)] public string[] LoadArray() Here\'s my javascript

Here's my web method

[WebMethod(EnableSession = true)]
public string[] LoadArray()

Here's my javascript

$.ajax({
        type: 'POST',
        url: '/services/Service.asmx/LoadArray',
        data: "{}",
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        success: function(arr) {
            for (v开发者_高级运维ar i = 0; i <= arr.length; i++) {
                addNewPatient(arr[i]);
            }
        }
    });


I tend to have my function return a string, and put the array of strings into one json result to pass back to the client.

Have you tried to do this?

What was the error message?


i fixed the problem

the array should be "arr.d"

0

精彩评论

暂无评论...
验证码 换一张
取 消