[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

Need some help with .ajax/jquery loading content after $.ajax post request.

Hello, I'm getting comments to load into the db just fine with the POST $.ajax request but during the success part I'm trying to load the id results with the index.cfm page. Doesn't seem to be working with what I have so far.

Thanks,

Brian
$("form#frmComment").submit(function(){

	var datastring= $('form#frmComment').serialize();
	$.ajax({
		type: "POST",
		url: "inc_comments.cfm",
		cache: false,
		data: datastring,
		success: function(){
			$("#results").get("index.cfm");
		}
	});// .ajax()
  }); // .submit()

Open in new window

0
brihol44
Asked:
brihol44
1 Solution
 
GregArnottCommented:
As you've made the submit, success and response in one, I believe you need to sync the return data for it to work.

ie:
$("form#frmComment").submit(function(){

	var datastring= $('form#frmComment').serialize();
	$.ajax({
		type: "POST",
		url: "inc_comments.cfm",
		cache: false,
		data: datastring,
		[b]async:false,[/b]
		success: function(){
			$("#results").get("index.cfm");
		}
	});// .ajax()
  }); // .submit()

Open in new window


Alternatively, set the process into the trilogy of $.ajaxSetup(), $.ajax() and $.ajaxSuccess()
0
 
brihol44Author Commented:
Awesome! It worked!

Thanks,

Brian
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now