atom feed7 messages in com.googlegroups.google-gadgets-apiRe: [iGoogle Developer Forum] Re: gad...
FromSent OnAttachments
KevinSep 22, 2010 1:57 pm 
KevinSep 23, 2010 5:14 am 
Rob RussellSep 28, 2010 1:36 pm 
KevinSep 29, 2010 1:08 pm 
KevinOct 1, 2010 5:00 am 
Rob RussellOct 1, 2010 3:07 pm 
KevinOct 6, 2010 12:24 pm 
Subject:Re: [iGoogle Developer Forum] Re: gadgets.io is undefined
From:Rob Russell (robr@google.com)
Date:Oct 1, 2010 3:07:04 pm
List:com.googlegroups.google-gadgets-api

If what you're receiving from the server is valid html then setting the innerHTML of an element in the DOM is one way to get at the response data with DOM methods. This should be similar to other cases where you have text that you want to treat as markup in a web page.

On Fri, Oct 1, 2010 at 5:01 AM, Kevin <kevi@solers.com> wrote:

OK - slowly breaking the code here.

If I change params[gadgets.io.RequestParameters.CONTENT_TYPE] to gadgets.io.ContentType.TEXT (from .DOM) then I can receive the HTML from the website, but apparently I can't treat it as a DOM object and access various elements (e.g. can't call obj.data.getElementsByTagName("table")).

If I have to use gadgets.io.ContentType.TEXT with HTML results from other webpages, how do I then call DOM methods to access various elements? Thanks!

On Sep 29, 4:08 pm, Kevin <kevi@solers.com> wrote:

I've figured out how to get my gadget into an iGoogle page by adding it via the "My Gadgets" gadget and it gets past the gadgets.io methods (but not in the GGE Preview pane). It now fails in the gadgets.io.makeRequest() callback function when I try to access the makeRequest argument. The error just says "undefined" when I try to do something with obj.data in the following code. Any suggestions?

<?xml version="1.0" encoding="UTF-8"?> <Module> <ModulePrefs title="Tester, the Gadget" title_url="http://www.fundalarm.com/" description="Simple gadget to look up mutual fund data on fundAlarm" author="Kevin" /> <Content type="html"><![CDATA[ <script type="text/javascript">

function makeDOMRequest() { var url = "http://www.fundalarm.com/fund.asp"; var params = []; var userdata = {"ticker1" : document.getElementsByName("ticker1") [0].value}; try { var postdata = gadgets.io.encodeValues(userdata); alert("Submitted: "+postdata); params[gadgets.io.RequestParameters.POST_DATA]= postdata; params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.DOM; params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.POST; gadgets.io.makeRequest(url, response, params); } catch(err) { alert("makeDOMrequest(): "+err.name+": "+err.message); }

}

function response(obj) { alert("In response()"); try { alert("About to try obj.data..."); var funddata = obj.data; alert(funddata); var tabledata = obj.data.getElementsByTagName("table"); var fundname = tabledata[1].rows[0].cells[0].innerHTML; alert("Fund: "+fundname); document.write("<br/><b>Fund: </b>", fundname, "<br/>"); //add more code when this is working... } catch(err) { alert("response(): "+err.name+": "+err.message); } } </script>

<div> <CENTER>Enter a mutual fund symbol:<br/> <input type="text" maxlength=5 size=6 name="ticker1" /> <input type="button" value="Go" onclick="makeDOMRequest();" /> </CENTER> </div> <p>Testing xxx...</p> ]]></Content> </Module>

Kevin

On Sep 28, 4:37 pm, Rob Russell <robr@google.com> wrote:

I've seen similar problems when the Javascript starts to run before all resources are finished loading. Try starting your Javascript from an onload handler.

Rob Russell Google Developer Relations

On Thu, Sep 23, 2010 at 5:14 AM, Kevin <kevi@solers.com>

wrote:

More details: The HTML renders OK in the GGE Preview pane. The javascript error occurs when I click a button that calls a javascript function that uses several gadgets.io methods and fields.

One other question about GGE: the preview tab puts all the html in a small dashed-line box that significantly restricts the real estate. What is up with that? I can't seem to adjust it by setting the modulePrefs height and width.

On Sep 22, 4:58 pm, Kevin <kevi@solers.com> wrote:

Trying to create my first gadget using Google Gadget Editor in FF 3.6.8. Tried to use the gadgets.io.makeRequest() method per the Gadgets API Reference (http://code.google.com/apis/gadgets/docs/ reference/) and the error console only says "gadgets.io is undefined". No other errors. What am I doing wrong?

-- You received this message because you are subscribed to the Google Groups "iGoogle Developer Forum" group. To post to this group, send email to Goog@googlegroups.com. To unsubscribe from this group, send email to Google-Gadgets-API+unsu@googlegroups.com<Goog@googlegroups.com>

<Goog@googlegroups.com<Goog@googlegroups.com>

. For more options, visit this group at http://groups.google.com/group/Google-Gadgets-API?hl=en.