jquery ajax call fails and returns error on facebo

2019-08-12 08:15发布

问题:

I'm trying to add a form to a Facebook page through "Static HTML: iframe tabs" app. I am using jQuery,ajax,php to send the form and recieve success or error. When I run the form outside of Facebook iFrames everything works fine. But, on iFrames I've encountered two problems:

  1. AJAX call fails each time. It returns error value and does not pass values.
  2. Google chrome gives me "this page has insecure content"

here is my ajax call:

$.ajax({
    type: "POST",
    url: "send.php",
    contentType: "application/x-www-form-urlencoded; charset=utf-8;",
    data: data_string,  
    dataType: 'html',
    success: function(data){
        alert('success');
    },
    error: function() {
        alert('error');
    }
});

Thanks in advance.

回答1:

Solved. The problem was indeed Facebook's demand for secure connections in iFrames. All that needed to be done was to store the file on a web hosting service with SSL. Then make sure all links on html pages are with "https".

This solved both of the problems stated above.