Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use external datasource - asp webservice #25

Open
Misiu opened this issue May 31, 2012 · 1 comment
Open

How to use external datasource - asp webservice #25

Misiu opened this issue May 31, 2012 · 1 comment

Comments

@Misiu
Copy link

Misiu commented May 31, 2012

Hi all, I am wondering how to use external data source, but not json file, but asp webservice.

If I do this:

source: dataPath + "js/Meetings.js"

gantt is displayed correct,

but if I do this:

source: dataPath + "Meetings.asmx/GetAll" 

I get error:

[InvalidOperationException]: Format żądania jest nierozpoznany dla adresu URL nieoczekiwanie kończącego się w /GetW”.
   w System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response)
   w System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath)
   w System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated)
   w System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
   w System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   w System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

How to correct this or any ideas how to use asp webservice result?

@Misiu
Copy link
Author

Misiu commented May 31, 2012

Got this working.
I had to change piece of code:

create: function (element) {
    if (typeof (settings.source) == 'object') {

        if (settings.source.hasOwnProperty("d")) element.data = settings.source.d;
        else element.data = settings.source;
        core.init(element);
    } else {
        $.ajax({
            type: 'POST',
            contentType: 'application/json; charset=utf-8',
            data: '{}',
            dataType: 'json',
            url: settings.source,
            success: function (result) {
                if (result.hasOwnProperty("d")) element.data = result.d;
                else element.data = result;
                core.init(element);
            }
        });
    }

}

Sorry for posting this here, but I don't know (for now) how to use github to post path.

I've added ajax instead of getJSON because but webservice wasn't parsed, now it is.
Second change was adding check for "d" property. .NET is wrapping json result in extra d element for security reasons.

Hope this helps.

mbielanczuk pushed a commit that referenced this issue Jan 31, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant