Sharp Posted March 30, 2007 Share Posted March 30, 2007 ok, so I'm trying to set up one button to link to a php script that will read from a file and display the results on the page. Running the php file itself will diplay what I want, but I cant integrated it into the html page properly..... The Javascript: <script type="text/javascript" src="/dojoSrc/dojo.js"></script> <script type="text/javascript"> dojo.require("dojo.dnd.*"); dojo.require("dojo.event.*"); dojo.require("dojo.widget.*"); dojo.require("dojo.widget.Button"); function byId(id){ return document.getElementById(id); } function buttonReadPressed() { // bind button to script, function and form dojo.io.bind({ url: 'test2.php', handler: updateStatus, }); } function updateStatus(msg) { msg = "<p>"+msg+"</p>" if(elem = document.getElementById("thread1")) elem.innerHTML = msg; } function init(){ var readButton = dojo.widget.byId('readButton'); dojo.event.connect(readButton, 'onClick', 'buttonReadPressed') } dojo.event.connect(dojo, "loaded", "init"); </script> the associated html <button dojoType="button" id="readButton">View Sample Post</button> <div id="thread1"></div> what happens when I click the button is that just the word "load" is returned, like so Before Click: After Click: I dont really think I need to post the php, because like I said, it runs fine..... I just can't get it's output to show up on the main page. Any Ideas? Quote Link to comment Share on other sites More sharing options...
Sharp Posted March 31, 2007 Author Share Posted March 31, 2007 Yeah, I knew it was something simple. I used code from another project that bound a different function to the button, and that function then called my updatestatus function. I copied the code, but left out the middle function, and forgot to update the updatestatus function from function updateStatus(msg) {} to function updateStatus(type, data, evt) { msg = data; } just having it the first way made msg = type, which (apparently) is always 'load'. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.