Solved

jquery dialog and posting data

Posted on 2014-01-07
7
209 Views
Last Modified: 2014-01-07
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
Comment
Question by:debbieau1
  • 4
  • 2
7 Comments
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 39761880
Line 19:

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

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

testrequest : $("#testrequest").val(),
0
 
LVL 1

Author Comment

by:debbieau1
ID: 39761894
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
 
LVL 1

Author Comment

by:debbieau1
ID: 39761907
must not have cleared cache sorry it works.  thanks very much
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 82

Expert Comment

by:leakim971
ID: 39761908
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
 
LVL 1

Author Comment

by:debbieau1
ID: 39761910
sorry leakim, I accepted answer and didnt see your response.  You have always been terrific.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39761913
no worry, please double check where you're putting :
 << testrequest : $("#testrequest").val(), >>
0
 
LVL 1

Author Comment

by:debbieau1
ID: 39761914
Thanks so much
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question