Jump to content

Ajax Newb Getting Syntax Error


BlendsInWell

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.