Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3855066
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:43:08+00:00 2026-05-19T17:43:08+00:00

I currently have a web based application which strictly relies on a 3rd party

  • 0

I currently have a web based application which strictly relies on a 3rd party soap server to supply the site with information. This application has little to no javascript, a few elements pulled from jQuery UI and a few jQuery things (more for simplicity than any other reason).

This application is coming back around for feature enhancements and my thoughts are based on the soap server we rely on for data and each soap request requires a round trip we really want to reduce making multiple round trips on a single http request. Therefore, my thought was to make the application ajax based and only update content areas where the user wishes to see.

So we have this server side library, php based, which uses soap to get information, generate HTML and send that data to the user. Now the fun begins, we want to take this server side code and make it modular and build a jQuery plugin to interact with server side. The part I am having trouble gathering is how to have multiple functions in a plugin (perhaps this is the wrong approach, please correct me) where I can call each one at will.

The basic idea is the following:

The soap server allows access to all of its underlying tables, each table has a specific WSDL and defines a set of functions available for each table. These functions are the same for all tables.

We have for example:

  • get
  • getRecords
  • insert
  • update
  • delete

    (function( $ ){
    var methods = {
        init: function( options){
            //initialize the plugin 
            return this.each(function(){
                var $this = $(this),
                    data = $this.data();
            });
        },
        get : function(id){
            var getQuery = 'sys_id='+id;
            $.ajax({
                type: "POST",
                url: "get.php",
                data: getQuery,
                cache: false,
                success: function(result){
                    if(result.error){
                        //error notify user error occured... 
                    }else{
                        //success, update user ... 
                    }
                }
            });
            return false;
        },
        getRecords : function( ){
    
        },        
    };
    
    $.fn.myPlugin = function ( method ){
        if( methods[ method ]){
            return methods[ method ].apply(this, Array.prototype.slice.call( arguments,     1 ));
        }else if(typeof method === 'object' || !method){
            return methods.init.apply(this, arguments);
        }else{
            $.error('Method ' + method + 'does not exist on jQuery.ServiceNow');
        }
    };
    })( jQuery );
    

So a get call to soap server would require a ID to identify which record in the table, a getRecords call accepts a query and returns multiple records, insert inserts a record, update updates a record etc.

To perform a get call I wanted to do something such as:

 $("#div").myPlugin.get(arguments); 

The result would be that the div with id=”div” would be updated with the return of whatever the get Function in the plugin myPlugin defined to do with that element.

Is this the right approach, is there a better approach, am I all wet? This is my first jQuery plugin and I feel I am coming from the object oriented world where I am used to constructed things and then calling functions/methods of them and/or using fields. And maybe this is the problem that my mentality is off.

Appreciate comments/feedback!

My thoughts were to construct something similar in a jQuery plugin to be able to pass these calls to the server and the php on the server would determine the WSDL location based on what resource you want.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:43:08+00:00Added an answer on May 19, 2026 at 5:43 pm

    This is a simple and valid approach, though with the code you’ve shown, you’d call .get like this instead:

    $('#div').myPlugin('get', arguments);
    

    This is the approach that jQuery UI uses. As such you may want to look into how their Widget Factory works, or even incorporate it into your own code.


    An alternative approach to get a similar syntax to your example:

    var methods = {/* Methods same as above */};
    
    $.fn.myPlugin = function() {
        var Obj = function () {},
            obj;
    
        Obj.prototype = methods;
        obj = new Obj();
        obj.els = this;
    
        return obj;
    };
    

    And call it like this:

    $('#div').myPlugin().get(arguments);
    

    And if you need to reference this within your methods to refer to the selected jQuery object (e.g. $('#div')), use this.els instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a 3rd-party rotator object, which is providing a smooth, random rotation
I want to have generalised email templates. Currently I have multiple email templates with
We manage a site for a medical charity. They have a number of links
IE is giving me an undefined NAN when i try to view the calender...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.