Solved

Fancybox Jquery Form

Posted on 2010-05-14
4
1,846 Views
Last Modified: 2012-05-09
Hi

I have a link to display a user form winthin a fancybox
a perl script gets the data from a database and populates a simple user form Name Contact info etc

on hiting update the same script updates the database & displays a Thank You message this works within a a seperate brouser window.
In the Fancybox window all that happens is the box closes and the parent window refreses and the datbase table remains untouched so i'm unable to tell what is happing because i can't get any message back

I'm using the example from http://fancybox.net/blog


Javascript

Attach FancyBox: 
$("a#UsrFrm").fancybox({
	'scrolling'		: 'no',
	'titleShow'		: false,
	'onClosed'		: function() {
	    $("#login_error").hide();
	}
});
Simple validation; submit data using Ajax and display response
$("#login_form").bind("submit", function() {

	if ($("#login_name").val().length < 1 || $("#login_pass").val().length < 1) {
	    $("#login_error").show();
	    $.fancybox.resize();
	    return false;
	}

	$.fancybox.showActivity();

	$.ajax({
		type		: "POST",
		cache	: false,
		url		: "UsrForm.pl",
		data		: $(this).serializeArray(),
		success: function(data) {
			$.fancybox(data);
		}
	});

	return false;
});

Open in new window

0
Comment
Question by:trevor1940
[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
  • 3
4 Comments
 
LVL 15

Expert Comment

by:StealthyDev
ID: 32712196
Try

        $.ajax({
                type            : "POST",
                cache   : false,
                url             : "UsrForm.pl",
                data            : $(this).serialize(),
                success: function(data) {
                        $.fancybox(data);
                }
        });
0
 
LVL 1

Author Comment

by:trevor1940
ID: 32713022
senthurpandian:
changing
 data: $(this).serializeArray(),
to
      data      : $(this).serialize(),

didn't have any effect
0
 
LVL 1

Author Comment

by:trevor1940
ID: 32714715
It has occerd to me that the example loads the form within the parent Document and then hides it I'm trying to load the form from an external perl script which is failing

To load the form i use UsrForm.pl?userid=1234&Switch=A

this Queries the Database and populates the form
within the form there is an hidden input box with Switch = B

this then tells the same perl script to up date the Database

Is there a better way of doing this

Thank you
0
 
LVL 1

Accepted Solution

by:
trevor1940 earned 0 total points
ID: 32806785
I managed to fix this by calling the child perl script into an iframe
The examle works when the pparent document is a html doc it dosn't work when it is a perl script
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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 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…

738 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