Jquery calling svc service methods

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
9/12/2011 4:28:48 AM
Gravatar
Total Posts 88

Jquery calling svc service methods

Hi

I´ve a module with several controls that loads with jquery ajax methods from a aspx page with [WebMethods].

Now to customize this module i need to call the service directly to my WCF service library like:

mojoportal/Services/ModuleServices.svc/method.

but like the same function i´ve called from an aspx page that works fine when i change to svc "page" jquery return an bad request? there´s any idea?

Its an user control inside in another.

aspx call: works fine

var url = "Page.aspx/Method";
        $.ajax({
            url: url,
            data: "",
            type: "POST",
            contentType: 'application/json; charset=utf-8',                     
            timeout: 10000,
            dataType: 'json',
            success: function (value) {
                alert(value.d);
            },
            error: AjaxFailed

        });

directly to an svc call doesnt work

var url = "../Services/ServiceModule.svc/Method";
        $.ajax({
            url: url,
            data: "",
            type: "POST",
            contentType: 'application/json; charset=utf-8',                    
            timeout: 10000,
            dataType: 'json',
            success: function (value) {
                alert(value.d);
            },
            error: AjaxFailed

        })

 

9/12/2011 2:14:08 PM
Gravatar
Total Posts 18439

Re: Jquery calling svc service methods

you need to set break points in your service and see if it is even being called. I would use an url relative to the root of the site ie /Services/ServiceModule.svc/Method not ../Services/ServiceModule.svc/Method

it also looks inconsistent, is it ServiceModule.svc or ModuleService.svc? you've listed it both ways.

you can also use firebug and see what is the status code returned from the ajax request.

Hope that helps,

Joe

9/13/2011 4:08:11 AM
Gravatar
Total Posts 88

Re: Jquery calling svc service methods

thanks joe for the help,

i´ve tried some different configuration of service but i cant call them with svc base.

Using fiddler and firefox I have this error:

HTTP/1.1 415 Cannot process the message because the content type 'application/json; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.

with break point i cant go to the service but if i call the service with an [WebMethod] on an aspx Page the service was called successful.

I´ve called by the WCF Test Client and works fine.

I cant find what is wrong.

 

You must sign in to post in the forums. This thread is closed to new posts.