Skip to content

Instantly share code, notes, and snippets.

@segebee
Created March 31, 2018 17:40
Show Gist options
  • Save segebee/9a22efae6a1223c3cfffef738130dc0c to your computer and use it in GitHub Desktop.
Save segebee/9a22efae6a1223c3cfffef738130dc0c to your computer and use it in GitHub Desktop.
function startStalking($,stalked)
{
if (stalked === true) return;
var stalker_url = base_url+'api/stalker';
var stalkerTarget = {};
var index = 0; //first occurence of an element will be sent
//get primcipal details
//get sponsor details
stalkerTarget.s_firstname = $('#s_firstname').val();
stalkerTarget.s_lastname = $('#s_lastname').val();
stalkerTarget.s_email = $('#s_email').val();
stalkerTarget.s_phone = $('#s_phone').val();
//get personal details
stalkerTarget.title = $('.title').eq(index).val();
stalkerTarget.firstname = $('.firstname').eq(index+1).val();
stalkerTarget.lastname = $('.lastname').eq(index+1).val();
stalkerTarget.email = $('.email').eq(index).val();
stalkerTarget.phone = $('.phone').eq(index+1).val();
stalkerTarget.dob = $('.dob').eq(index).val();
stalkerTarget.sex = $('.sex:checked').eq(index).val();
stalkerTarget.marital_status = $('.marital_status:checked').eq(index).val();
stalkerTarget.residential_address = $('.residential_address').eq(index).val();
stalkerTarget.states = $('.states').eq(index).val();
stalkerTarget.lgas = $('.lgas').eq(index).val();
stalkerTarget.residential_mailing_address = $('.residential_mailing_address').eq(index).val();
stalkerTarget.mailing_address = $('.mailing_address').eq(index).val();
stalkerTarget.hospital_states = $('.hospital_states').eq(index).val();
stalkerTarget.hospital_choice = $('.hospital_choice').eq(index).val();
stalkerTarget.avatar_name = $('.avatar_name').eq(index).val();
//console.log("stalkerTarget: ",stalkerTarget);
//send stalked data over the wire
$.post( stalker_url,stalkerTarget,function( data ) {
}).done(function(data,status,statusText) {
stalked = true;
//console.log('success data ',data);
//console.log('status ',status);
//console.log('statusText ',statusText);
}).fail(function(data,status,statusText) {
//console.log(' fail statusText ',statusText);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment