Resubmitting or Creating a Nested jQuery.post

Solution:

You have to create a function to call again within jQuery.post response. try the below code.

// build data
var dataURL = dataURLs[0],
    data = {
        email: email,
        name: name,
        linkforsharedURL: linkforsharedURL 
    };

SendDataToPhp( data );

function SendDataToPhp(){
    // send data
    jQuery.post("<?php echo admin_url('admin-ajax.php'); ?>", data, function(response) {
        if (response.share_id !== undefined) {
            var pattern = new RegExp('(share_id=).*?(&|$)'), shareUrl = window.location.href;
            if (shareUrl.search(pattern) >= 0) {
                shareUrl = shareUrl.replace(pattern, '$1' + response.share_id + '$2');
                linkforsharedURL = shareUrl;
                data.linkforsharedURL = 'updated value to send';
                SendDataToPhp( data );
            }
        }
    });
}