JQuery Validate & Loading Tracking Image

Closed - This job posting has been filled and work has been completed.
Web, Mobile & Software Dev Web Development Posted 2 years ago

Fixed Price

Delivery by January 30, 2013

$20.00

Budget

Details

I have a JQuery validate event on my form.

            $("#form").validate({
                rules: {
                    firstname: "required",
                    lastname: "required",
                    email: {
                        required: true,
                        email: true
                    },
                    cellphone: {
                        required: true,
                        phoneUS: true
                    }
                },
                messages: {
                    firstname: "Please specify your first name",
                    lastname: "Please specify your last name",
                    email: {
                        required: "Please enter your email address",
                        email: "Your email address must be in the format of name@domain.com"
                    }
                }
                
            });


This works fine.

However if the form successfully validates, I want to run the following code:

var img = document.createElement("img");
var goalId = 123456;
var randomNum = new Date().getMilliseconds();
var value = 100;
var label = "label";
var url = encodeURI(location.href);

var trackUrl = "http://www.googleadservices.com/pagead/conversion/"+goalId+"/?random="+randomNum+"&value="+value+"&label="+label+"&guid=ON&script=0&url="+url;
img.src = trackUrl;
document.body.appendChild(img);

and I can't get it to work!! It is critical that the image loads fully before the form is actually submitted as well.

Please help.


About the Client

(5.00) 141 reviews

United States
Kalamazoo 08:12 AM

203 Jobs Posted
78% Hire Rate, 1 Open Job

Over $50,000 Total Spent
174 Hires, 3 Active

$8.19/hr Avg Hourly Rate Paid
5,891 Hours

Member Since Jul 13, 2009