Jump to content

Recommended Posts

hey all!

i'm using jQuery and trying to submit a form without page refresh. so far it's working but it will not display the output of the php file. heres the jQ code i have so far:

$(document).ready(function() {
$(".button").click(function() {
	$("#output").hide();
	$("#loading").fadeIn();

	var title = $("input#title").val();
	var year = $("input#year").val();
	var type = $("select#type").val();
	var encoder = $("input#encoder").val();

	var dataString = 'title='+ title +'&year='+ year +'&type='+ type +'&encoder='+ encoder;
	//alert(dataString);return false;
	$.ajax({
		type: "POST",
		url: "gen.movie.php",
		data: dataString,
		success: function() {
			$("#loading").fadeOut();
			$("#output").html(dataString.responseText); <--- ***NOTE***
			$("#output").fadeIn(1000);
		}
	});
});
return false;
});

php file:
echo $_POST['title'];

 

***NOTE***

i think problem starts there cause firebug gives me right return. any ideas..?!  :shrug:

Link to comment
https://forums.phpfreaks.com/topic/184282-submit-with-ajax-not-working/
Share on other sites

I've never used jQuery before but a quick search turned this example up...i think you are requesting the response incorrectly.

 

bodyContent = $.ajax({
      url: "script.php",
      global: false,
      type: "POST",
      data: ({id : this.getAttribute('id')}),
      dataType: "html",
      success: function(msg){
         alert(msg);
      }
   }
).responseText;

I've never used jQuery before but a quick search turned this example up...i think you are requesting the response incorrectly.

 

bodyContent = $.ajax({
      url: "script.php",
      global: false,
      type: "POST",
      data: ({id : this.getAttribute('id')}),
      dataType: "html",
      success: function(msg){
         alert(msg);
      }
   }
).responseText;

both, my and your code, works. i just have no idea how do display returned data in html.

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.