检测是否加载了Facebook评论

时间:2016-01-16 21:07:29

标签: javascript jquery

如果facebook评论iframe已加载,如何使用jQuery检测。我懒得加载评论。

我尝试了以下但是它没有用。

function deliver_mail() {

if ( isset( $_POST['w-submitted'] ) ) {
    $first_name = sanitize_text_field( $_POST['m-first-name'] );
    $last_name = sanitize_text_field( $_POST['m-last-name'] );
    $contact_number = sanitize_text_field( $_POST['m-contact-number'] );
    $email = sanitize_email( $_POST['m-email-address'] );
    if(isset($_POST['m-current-location'])) {
        $current_location = $_POST['m-current-location'];
    }
    $current_position = sanitize_text_field( $_POST['m-current-position'] );
    $city = sanitize_text_field( $_POST['m-city'] );
    $years_experience = sanitize_text_field( $_POST['m-experience-years'] );
    $qualifications = sanitize_text_field( $_POST['m-qualifications'] );
    if(isset($_POST['m-position'])) {
        $position = $_POST['m-position'];
    }        
    $other_position = $_POST['m-other-position'];
    if(isset($_POST['m-applied-location'])) {
        $applied_location = $_POST['m-applied-location'];
    }
    $expected_salary = sanitize_text_field( $_POST['m-expected-salary'] );
    $availability = sanitize_text_field( $_POST['m-availability'] );
    $referral_source = sanitize_text_field( $_POST['m-referral-source'] );
    if(isset($_FILES['m-upload-resume']['tmp_name'])) {
        $attachment = chunk_split(base64_encode(file_get_contents($_FILES['m-upload-resume']['tmp_name'])));
        $filename = $_FILES['m-upload-resume']['name'];
    }

    $boundary =md5(date('r', time()));

    $to = get_option( 'admin_email' );

    $subject = "Job applicant: $first_name $last_name";

    $headers = "From: $first_name $last_name <$email>" . "\r\n";

    $message = "First Name: $first_name \r\nLast Name: $last_name   \r\nContact Number: $contact_number \r\nCurrent Country: $current_location \r\nCurrent Position: $current_position \r\nCity: $city \r\nYears Experience: $years_experience \r\nQualifications: $qualifications \r\nDesired Position: $position \r\nOther Position: $other_position \r\nExpected Salary: $expected_salary \r\nAvailability: $availability \r\nReferral Source: $referral_source";

    $headers .= "\r\nMIME-Version: 1.0\r\nContent-Type: multipart/mixed; boundary=\"_1_$boundary\"";

    $message = "This is a multi-part message in MIME format.

--_1_$boundary
Content-Type: multipart/alternative; boundary=\"_2_$boundary\"

--_2_$boundary
Content-Type: text/plain; charset=\"utf-8\"
Content-Transfer-Encoding: 7bit

$message

--_2_$boundary--
--_1_$boundary
Content-Type: application/octet-stream; name=\"$filename\"
Content-Transfer-Encoding: base64
Content-Disposition: attachment

$attachment
--_1_$boundary--";

    // If email has been processed for sending, display a success message
    if ( wp_mail( $to, $subject, $message, $headers  ) ) {
        echo '<div id="contact-response">';
        echo '<p>Thank you for your interest in joining our team. We look forward to reviewing your application.</p>';
        echo '</div>';
    } else {
        echo 'Sorry, an unexpected error occurred. Please refresh the page and try again.';
    }
}

}

感谢。

1 个答案:

答案 0 :(得分:1)

加载Facebook JS SDK时,您需要订阅xfbml.render事件:

FB.Event.subscribe('xfbml.render', function() {
     alert('the iframe is done loading');
});