Go Premium for a chance to win a PS4. Enter to Win

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

jquery dialog and posting data

Would be great to help on this.  I'm sure someone with a good eye will see problem quickly.   It is not posting the value to the php script


		function myTester(thetitle)
		{
				$('<div>'+
				  '<input type="text" id="testrequest" placeholder="What is the name?" size="60"/>'+
				  '</div>').dialog({
				dialogClass:'shareClass',
			        title: thetitle,
			        width: 600,
					height: 300,
			        close: function(event, ui) { $(this).remove(); },
			        position: ['center','center'],
			        modal: false,
			        buttons: [
			            {
			                text: "Send Request",
			                click: function() { 
							$.ajax({
								url:'forms/sendResults.php',
								var testrequest=$("#testrequest").val(),
								type:'post',  
								data: $(testrequest).serialize(),
								success:function(result){
									$("button").html(result);
								}
							});
				  				$( this ).dialog( "close" ); 
							}
			            },
				     {
			                text: "Close",
			                click: function() { 
	
				  		$( this ).dialog( "close" ); 
					}
			            }

			        ]
			    });

Open in new window

0
debbieau1
Asked:
debbieau1
  • 4
  • 2
1 Solution
 
Tom BeckCommented:
Line 19:

var testrequest=$("#testrequest").val(),

This is not the syntax of a property. Did you mean:

testrequest : $("#testrequest").val(),
0
 
debbieau1Author Commented:
Thanks for such quick response.  Didnt solve it, but you did pick up one  syntax error.


This is what I have in the php script.

<?php echo "this is my test and should post value ".$_POST['testrequest'];

It should echo the value from the dialog.  The value is not posting to php script
0
 
debbieau1Author Commented:
must not have cleared cache sorry it works.  thanks very much
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
leakim971PluritechnicianCommented:
Try this :
function myTester(thetitle)
{
	$('<div><input type="text" id="testrequest" placeholder="What is the name?" size="60"/></div>').dialog({
		dialogClass:'shareClass',
		title: thetitle,
		width: 600,
		height: 300,
		close: function(event, ui) { $(this).remove(); },
		position: ['center','center'],
		modal: false,
		buttons: [
			{
				text: "Send Request",
				click: function() { 
					$.post('forms/sendResults.php', { testrequest: $(testrequest).val() }, function(result){ alert(result);$("button").html(result);});
					$( this ).dialog( "close" ); 
				}
			},
			{
				text: "Close",
				click: function() { 
					$( this ).dialog( "close" ); 
				}
			}
		]
	});
}

Open in new window

0
 
debbieau1Author Commented:
sorry leakim, I accepted answer and didnt see your response.  You have always been terrific.
0
 
leakim971PluritechnicianCommented:
no worry, please double check where you're putting :
 << testrequest : $("#testrequest").val(), >>
0
 
debbieau1Author Commented:
Thanks so much
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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