PDA

View Full Version : [CLOSED] AjaxMethod error



Jurke
Nov 06, 2008, 5:25 AM
Hi
Im trying the Sandbox example "AjaxMethod.aspx" but I get a runtime error on this line





Coolite.Ext.AjaxMethods.callMethod({ methodName: "Sum", params: { a: a, b: b }, success: success, failure: failure });

With the error "Coolite.Ext.AjaxMethods" is null or not an object

Any ideas?

Best regards
Mikael Jürke

geoffrey.mcgill
Nov 06, 2008, 5:30 AM
Please SVN update. That line has been commented out. I was just mocking up some new syntax. 

Jurke
Nov 06, 2008, 6:00 AM
Okay thanks.

I have a ajax method that returns a string, in the succes funcion. quotes are added to the value ->"VALUE"<-. Why is that, can you make that go away please?







[AjaxMethod]
public static string Teststring strVal)
{
return strVal+"_AJAX";
}

I really love that you implemented the AjaxMethod BIG THANKS!

/Mikael

geoffrey.mcgill
Nov 06, 2008, 6:05 AM
Hi Mikael,

The [AjaxMethod] feature is not complete yet. Please expect all existing [AjaxMethod] JavaScript syntax to change during the next couple days. 

Jurke
Nov 06, 2008, 6:13 AM
Okay, sure.
How will I be aware of which syntax to use? Will it be available in the sandbox?

/Mikael

Jurke
Nov 06, 2008, 6:29 AM
I noticed an other thing, maybe you already know this. But anyway. I have a KeyDown event, in this keyevent I have a before event (CheckKey) that I hook a JS function to, in this function I call a AjaxMethod. When the ajaxmetod finished, in the before, it run the OnEvent "RunEventFunction", but the changed that are made to the page in this function does not reflect on the screen? If I commet out the AjaxMethod call in the before function "CheckKey" it works fine.






<ext:TextField ID="txtField" EnableKeyEvents="true" runat="server">
<AjaxEvents><KeyDown OnEvent="RunEventFunction" Before="return CheckKey(params[1]);"></KeyDown></AjaxEvents>
</ext:TextField>

Vladimir
Nov 06, 2008, 7:20 AM
Hi,

interesting how you implement CheckKey function

Do you wait result in cycle? Can you show full example?

Jurke
Nov 06, 2008, 7:49 AM
Hi my code look something like this.
But not exactly like this, but the fuctionallity is the same.






function CheckKey(e)
{
if(e.getKey() == e.ENTER)
{
e.preventDefault();
return true
}


if(e.getKey() == e.F7 || e.getKey() == e.F8)
{
var Id = txtId.getValue();
if (e.getKey() == e.F7)
GetNextIdJSWrapper(Id, 1);
if (e.getKey() == e.F8)
GetNextIdJSWrapper(Id, 2);





e.preventDefault();


return true


}
return false;
}


var GetNextBookingIdJSWrapper = function(Id, Direction) {





var params = {strBookingId: Id, strDirection: Direction};





Coolite.Ext.AjaxEvent.callStaticMethod('GetNextBoo kingId', params, GetNextIdSuccess, GetNextIdFailure);





}





var GetNextIdSuccess= function (value)
{
value = value.replace(/"/g,'')
txtId.setValue(value);
}





var GetNextIdFailure= function (msg)
{
alert('Error getting next id: ' + msg);
}




public static string GetNextId(string strId, string strDirection)
{
string strNextBookingId = "";
int intId = int.parse(strId)
if (strDirection == "1")
intId--;
else if (strDirection == "2")
intId++;

return intId.ToString();
}



/Mikael

Vladimir
Nov 06, 2008, 8:38 AM
Hi Mikael ,

you said that you call ajax method in CheckKey.

Does the GetNextIdJSWrapper is ajax method? If yes then please show code.

Or it is better to show full working example. Just strange that in ajax event using ajax method. All ajax methods it is async methods. If you call ajax method in before handler of ajax event then you will have two parallel ajax request. In my opinion it is make no sense (but may be I wrong). In any way, if you show full example then it can help us to resolve issue

Jurke
Nov 06, 2008, 9:19 AM
Sorry I dont have time to procude a working full example right now.

The "GetNextIdJSWrapper" calls the "GetNextId" that is a AjaxMethod.
I dont call an AjaxMethod in a AjaxEvent, But I call a AjaxMethod in the before event on a AjaxEvent. Maybe that is the same thing, and is wrong. You tell me! I want you to tell me how to do it the right way.

I can change the AjaxEvent to a <Listener> handler="CheckKey(params[1])" , but then the "params[1]" parameter in the CheckKey function was not recognized.

Please let me know if Im unclear.

Hope you can help me sort this out.

/Mikael

geoffrey.mcgill
Nov 06, 2008, 9:45 AM
Hi Mikael,

Personally, I would prefer if you could avoid experimenting with the [AjaxMethod] functionality until we/I make some statement about it being ready to test. The code and examples are still being worked on and we have not stated anywhere that this functionality is ready to use. I would just rather avoid you (or anyone) wasting precious time trying to figure how to use [AjaxMethods] or debugging code.


Summary: At the moment, the [AjaxMethod] functionality is not ready, but should be soon. 

Jurke
Nov 06, 2008, 9:48 AM
Ok sure, that sound smart. Where will it be announced when its ready?

/Mikael

geoffrey.mcgill
Nov 06, 2008, 9:50 AM
Sorry, forgot to mention one other thing...

The original support request for this thread has been solved. Please try to start a new thread if you have a different topic. 


I've marked the thread as [CLOSED]. New topic = New thread. Keeping unique topics separated into individual forum threads really helps us keep things organized.

Jurke
Nov 06, 2008, 9:52 AM
Yes sorry about that

/Mikael