1

I am have page tracking / tracking pixel page that is currently using $.post(PAIRS-DATA) to post the information being collected in the JavaScript back to the server. Then finally loads as a tracking pixel.

        finally
        {
            //tracking pixel
            Response.ContentType = "image/gif";
            byte[] buffer = pix.BinaryData;
            int len = buffer.Length;
            Response.OutputStream.Write(buffer, 0, len);

        }

The problem is, $.post(PAIRS-DATA) is canceled in Chrome, because it's cross domain. So I tried

         $.ajax({
            type: "POST",
            dataType: "jsonp",
            jsonp: false,
            processData: false,
            crossDomain: true,                
            url: "URL",
            data: dataPairs
        });

This take care of the cross domain issue but I now get "Resource interpreted as Script but transferred with MIME type image/gif:"

How can I fix this? is there something wrong with the $.ajax call?

4

1 回答 1

1

您的 ajax 调用失败,因为 JSONP 要求服务器实际发送回 JSONP(即 JSON + 包装器)。

如果您必须在加载图像之前使用 JS 收集数据,您可以尝试在图像的查询字符串中传递所需的数据。

例子:

$(document).append('<img src="http://host.com/path/to/image?' + formatDataAsQueryString());

于 2013-08-22T19:40:04.900 回答