0

i need to give parameter to a function, i'm not sure how to do so i need to add a parameter in my read function so i can use the same function several times, i added a parameter called val and tested if its equal to the value i need to call a function, now my problem is that i don't know how to add that parameter in the read function in my script (objhandler.read('one') ?? )

in my .js file i have this :

 var objHandler = new Interact(); // create an object the the handler class in javascript file. using this object, we can access the methods in the handler class.

function SayRead() {
    try {
        objHandler.Read(function (serverResponse) {
            if (serverResponse.error == null) {   
                var result = serverResponse.result;
                if (result.length > 2) {
                    SessionStore.loadData(Ext.decode(result));
                }
            }
            else {
                alert(serverResponse.error.message);
            }
        }//eo serverResponse
        ); 
    } //eo try
    catch (e) {
        alert(e.message);
    }
}

SayRead();

in my .ashx.cs file i have :

public class Interact : JsonRpcHandler
{
    [JsonRpcMethod()]
    public string Read(string val)
    {
        // Make calls to DB or your custom assembly in project and return the result in JSON format. This part is making custom assembly calls.

        clsDBInteract objDBInteract = new clsDBInteract();
        string result;
        try
        {
            if (val == "one")
            result = objDBInteract.FetchSessionsJSON();
            //if (val == "two") result = objDBInteract.FetchJobsJSON();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        return result;
    }
}

P.S: i use jayrock library

thanks.

1
  • edited my code,thx, if u have more questions let me know Commented Jun 24, 2011 at 14:17

1 Answer 1

1

I think more details would be helpful. I assume you are using a library / toolkit like jayrock. Please let us know.

You might want to try

objHandler.Read('one', function (serverResponse) {

This is AFAIK the way Jayrock would create the function.

Sign up to request clarification or add additional context in comments.

10 Comments

thanks,yes i use jayrock, i tried this ,it doesnt work,and i dont get an error, the wierdest is that my code (in the question) work!!i dont understand how since the condition if (val=='one' is not satisfied
any specific details u need,just let me know.i really appreciate ur help,thx
Maybe you can have a look at the proxy as generated by Jayrock. Download xxx.ashx?proxy and see - you should find something like ... this[m[0]] = function /* Read */ (val, callback) ... If not, what do you instead find? What Jayrock version do you use?
Strange. The parameter "val" is not offered in your proxy, whereas it should. I assume you made everything to ensure cache is deleted (both client cache and ASP Output Cache) after you added the function parameter? Then you could take the downloaded proxy js-code and modify it, writing this[m[0]] = function /* Read */ (val, callback) { if (self.kwargs) return rpc(new Call(0, {val: val}, callback)); return rpc(new Call(0, [val], callback)); } -- but that is now really ugly :-)
Restart of the server (IIS service if nothing else helps), SHIFT-Reload on the client.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.