Solved

jquery dialog and posting data

Posted on 2014-01-07
7
207 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now