pizzipie Posted September 17, 2013 Share Posted September 17, 2013 <script type="text/javascript" > bakups.onchange=function () { var x=document.getElementById("bakups").selectedIndex; var mychoice=document.getElementsByTagName("option")[x].value var is_sure=window.confirm("Are you sure you want to bakup "+ mychoice); if (is_sure) { $.post("DbaseBakup.php", {'mybak': mychoice} , showData, "json"); showData(data) {alert(data)} // syntax error missing ; // showData(retdata) { // ditto// alert(retdata); // } //window.alert("OK, you backed up "+mychoice); return false; } else { alert("do something else"); return false; } }</script> The code above is what is causing me fits. Error is: Timestamp: 09/17/2013 03:35:27 PMError: SyntaxError: missing ; before statementSource File: http://localhost/DB-Web/testonly/DbaseRestoreTest.phpLine: 53, Column: 21Source Code: showData(retdata) { Any help apperciated. R Link to comment Share on other sites More sharing options...
justsomeguy Posted September 17, 2013 Share Posted September 17, 2013 Well, this is definitely an error: showData(data) {alert(data)} What are you trying to do there? Link to comment Share on other sites More sharing options...
pizzipie Posted September 18, 2013 Author Share Posted September 18, 2013 Just trying to get the response function to show json data returned from DbaseBakup.php. I knew it might not work but I tend to develop my scripts a little at a time since I'm not very experienced with Javascript/jquery. Link to comment Share on other sites More sharing options...
thescientist Posted September 18, 2013 Share Posted September 18, 2013 (edited) you should read about the syntax for functions http://www.w3schools.com/js/js_functions.asp now you have the syntax to define a callback function at the top of your script somewhere function showData(data){ console.log(data);} then just pass it to $.post like you are currently doing. you shouldn't have to manually call it yourself, but you do have to define it ahead of time. note: logging to the console is often more preferable then alerting. Gives you more detail about the object and doesn't stop page flow with an annoying popup Edited September 18, 2013 by thescientist Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now