Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

jquery dialog and posting data

Posted on 2014-01-07
7
Medium Priority
?
215 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 38

Accepted Solution

by:
Tom Beck earned 2000 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
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!

 
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

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.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
Suggested Courses

730 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