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

  • Home
  • SEARCH
  • 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 8424837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:06:52+00:00 2026-06-10T04:06:52+00:00

Hey all I am working on a json call that will implement Drupal’s services

  • 0

Hey all I am working on a json call that will implement Drupal’s services module with json. I am using jquery’s ajax function to call the function but I am getting an error stating that no parameters are being passed. When I look at the query string being posted I notice that sessid is not being passed even though its with the parameters. Below is what Im running.

// JavaScript Document
$(document).ready(function() {

    function drupalConnect(src) {
        $.ajax({
            url: src,
            type: 'POST',
            data: {
                method: 'system.connect'
            },
            success: function(data) {
                return data["result"]["sessid"];
            }
        });
    }

    function getTimestamp() {
        return Math.round((new Date).getTime() / 1000);
    }

    function randString(length) {
        var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
        var randomstring = '';
        for (var i = 0; i < length; i++) {
            var rnum = Math.floor(Math.random() * chars.length);
            randomstring += chars.substring(rnum, rnum + 1);
        }
        return randomstring;
    }


    var session_id = drupalConnect('http://localhost/drupal/services/json-rpc');
    var nonce = randString(10);
    var timestamp = getTimestamp();
    var username = "markusgray";
    var password = "Markus1990";
    var key = '2ae0392e0aebbfeeddefcc962ea1924f';
    var domain = 'localhost';

    var hashObj = new jsSHA(timestamp + ";" + domain + ";" + nonce + ";user.login", "TEXT");
    var hash = hashObj.getHMAC(key, "TEXT", "SHA-256", "HEX");

    var parameters = {
        hash: hash,
        domain_name: domain,
        domain_time_stamp: timestamp,
        nonce: nonce,
        sessid: session_id,
        username: username,
        password: password
    };

    var par = JSON.stringify(parameters);

    $.ajax({
        url: 'http://localhost/drupal/services/json-rpc',
        type: 'POST',
        dataType: 'json',
        data: {
            method: 'user.login',
            params: par
        },
        success: function() {

        }
    });
});​
  • 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-06-10T04:06:54+00:00Added an answer on June 10, 2026 at 4:06 am

    drupalConnect doesn’t return anything, also the return from the success callback is just thrown away. The best way to use the data returned from an ajax call is to use it in thee callback itself.

    function drupalConnect(src){
        $.ajax({
            url: src,
            type: 'POST',
            data:{method:'system.connect'},
            success: function(data){
                var session_id = data["result"]["sessid"]; 
                //use session_id here
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey all. I'm working on an application that was originally intended for HTML, but
Hey all I'm extremely new to jquery and ajax and I'm looking for some
Hey all Im working on a game for iphone using cocos2d and sdk 4.1
Hey all, I'm working on the graphics for an app that uses a mix
Hey all... I've got a jQueryUI tabs implementation that's pretty straightforward and working fine.
Hey all, I cannot seem to get a simple ajax working between a php
Hey all, I basically output content into a div like this using jquery: var
Hey, trying to post a file using curl and all is working great. I
Hey all i am in need of some help getting my code working correctly
Hey all. I'm wondering how to implement a timeout event in the System.Windows.Forms.Webbrowser control?

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.