2

i am Creating GUI Extension in tridion.i have loaded jquery.js by editor config for my Extension.i have also coded my Service.svc file having some operation contract and it is implemented too now i am trying to call post method of Ajax of jquery from ui but my xmlHttpRequst object is failing to send Data to server.is there is any restriction for ajax operarion or do we have to register all js script into parent class?... as in javascript (namespace pattern) it get used ..

[OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
    void GetCount(string Id,out string strResult);

implementation:

public void GetCount(string Id, out string strResult)
    {
        //Id = "tcm:23-43434";
        //apply logic here
        strResult = "Result of Logic";
    }

    $j.ajax({               
    url: "http://localhost:20263/Service.svc?Id"+tcmID,
    type: POST,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success:  function (result)
    {
        //unable to send request to server....[[[Error]]]
        [[[[[[Error]]]]]]...
    },
    error: fail,
    dataFilter: function (data)
    {
    }
});

this jquery Ajax code is hitting my service method proper in sample web Application...but when i added same svc with tridion gui extension it is not hiting...

Thanks in Advance..

  • Is it a cross-domain issue? What does your browser console window say? – robrtc Aug 28 '14 at 8:43
  • yes it is cross domain,robrtc..hey rob i copied ajax code to hit it not working..if i add in same project how to call.... – Pankaj786 Aug 28 '14 at 8:58
  • 1
    This could be the problem then. Can you deploy your Web Service under the Tridion IIS Website and therefore it would not be cross domain? Or, add CORS to the C# web service and also jQuery? I've lost a lot of time before with these cross domain issues and sometimes hosting it under the Tridion CMS website is the easiest. – robrtc Aug 28 '14 at 9:00
  • robrtc do you have any links to call service form jquery code to web service into the tridion and its steps...i seen usually they are using GET Method of AJAX..to request server...every where they are registering name spaces – Pankaj786 Aug 28 '14 at 9:08
  • Another idea could be that your popup is a Web App (not .html with jQuery) and then you pass the WebApp the URIs of items you want to process, and use Core Service within the WebApp to do the work. – robrtc Aug 28 '14 at 9:16
1

I would suggest not trying to use jQuery for this.

It is unnecessary as there is already a framework available that provides you with everything you need to call your web service model.

In fact, as soon as you configure the service in your model, a proxy JavaScript object is automatically created that allows you to call the web methods and handle success & failure. It is named the same as the fully qualified name of your web service, but with lowercase letters for the namespace.

The process for creating your own model is pretty simple and is documented on the following page (requires login): Creating a Data Model

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.