On Sat, Aug 1, 2009 at 9:28 AM, Nolan Darilek <[email protected]>wrote:
>
> OK, having more issues with this.
>
> First I tried changing to jsonCall. This results in a huge backtrace,
> which I don't have at hand ATM but which seems to indicate a parse error
> in the input string. Strange, as the input seems rather
> straight-forward, but I thought I'd ensure that I'm not handing the
> function garbage before claiming that it's broken. Only, I can't seem to
> figure that out either. Here's what I've got:
>
> def updatePosition(pos:String):JsCmd = {
> println("Got "+pos)
> Alert(pos)
> }
>
> def update(in:NodeSeq):NodeSeq = Script(JsRaw("""
> loc.onUpdate = function(lat, lon) {
> """+SHtml.ajaxCall(JsObj("lat" -> JsVar("lat"), "lon" ->
> JsVar("lon")), updatePosition _)._2.toJsCmd+""";
> }"""))
>
> The generated JS looks fine:
>
> <script type="text/javascript">
> //<![CDATA[
>
> loc.onUpdate = function(lat, lon) {
> liftAjax.lift_ajaxHandler('F41567931874MRB=' + {"lat": lat, "lon":
> lon}, null, null, null);
> };
> // ]]>
> </script>
>
you need to replace ajaxCall with jsonCall... that will Stringify your
JavaScript object.
>
>
> But the println shows that I'm getting handed "[object Object]".
> Shouldn't it be passed a JSON string?
No... ajaxCall does a toString on the thing that's being passed. jsonCall
does a JSON.stringify... the latter is what you want.
>
>
>
> >
>
--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---