BlendsInWell Posted February 24, 2010 Share Posted February 24, 2010 Hey everyone! Am I glad this forum exists! As the title suggests, I'm a complete Ajax newb. I m wrote a project to learn php, and my friend suggested I use javascript with Ajax as a front-end. I did just that. He helped me out with the Ajax. It all worked perfectly, that is, until I tried running it in a browser other than Firefox. I used Opera to debug the code, and it pointed to a line in my Ajax. Here's the form that triggers the process: <fieldset> <div><label for="website">Enter value <input type="text" id="website" name="website" value=""/></label></div> <div><label for="single"><input id="single" type="radio" name="scan_type" value="single"/>single page</label></div> <div><label for="deep"><input id="deep" type="radio" name="scan_type" value="deep"/>deep scan</label></div> <div><input id="initiate" type="button" value="Find adjectives!" onclick="letsgo();" /></div> </fieldset> The error is in the function that's called upon submission of the form (the letsgo function). Here's that code: function getMore() { $.ajax({ type: "POST", url: baseUrl+"/index/doparsing", data: {continue:1, website: $("#website").val(), scantype: $("input[@name=\'scan_type\']:checked").val()}, dataType: "json", success: function(data) { rawoutput(data["data"], data["total"]); $('#inprogress').show("slow"); if (data["finished"] == false) { getMore(); } }, error: function() { } }); } Opera tells me that the line "data: {continue:1, website:" is missing a '}' token. I'm very stuck. I beg of you to help me! I'd be incredibly grateful! Quote Link to comment Share on other sites More sharing options...
BlendsInWell Posted February 24, 2010 Author Share Posted February 24, 2010 I'm terribly sorry, but I just realized that the function I posted isn't the one initiated b=y the form submission. It is, however, the one in which the error is. Both functions are in the same file, so I'm guessing that upon form submission the entire js file is parsed by the browser. Quote Link to comment Share on other sites More sharing options...
BlendsInWell Posted February 27, 2010 Author Share Posted February 27, 2010 To summarize, I think the problem is in this code: $.ajax({ type: "POST", url: baseUrl+"/index/doparsing", data: {continue: 1, website: $("#website").val(), scantype: $("input[@name='scan_type']:checked").val()}, dataType: "json", success: function(data) { Which is called when a form that looks like this is submitted: <form> <fieldset> <div><label for="website">Root URL To Scan <input type="text" id="website" name="website" value="http://www.example.com/"></label></div> <div><label for="single"><input id="single" type="radio" name="scan_type" value="single" checked>single page</label></div> <div><label for="deep"><input id="deep" type="radio" name="scan_type" value="deep">deep scan</label></div> <div><input id="initiate" type="button" value="Find adjectives!" onclick="letsgo();"></div> </fieldset> </form> I've been messing with a lot of things in the code, but to no avail. Please, help a beginner out! Quote Link to comment Share on other sites More sharing options...
BlendsInWell Posted March 1, 2010 Author Share Posted March 1, 2010 I figured it out. I needed quotes around the word "continue". 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.