QtWebkit jquery ajax POST不起作用

时间:2012-08-06 09:41:02

标签: jquery ajax qt webkit

我有一个QT webkit HTML5应用程序,带有一个调用jQuery AJAX POST方法的按钮

<script>
        $(document).ready(function(){
            $('#bntLogin').click(function(){
                var usrn = $('#txtUsername').val();
                var pwd = $('#txtPassword').val();

              $.ajax({
                url: 'http://www.ngg-l.com/Account/ClientLogin/',
                type: 'POST',
                data: { username: usrn, password: pwd },
                dataType: 'json',
                success: function (result) {
                    alert(result);
                },
                error: function(xhr, ajaxOptions, thrownError){
                    alert(xhr.status);
                    alert(thrownError);
                }
               });
            });
        });
    </script>

xhr.status = 0

有谁知道为什么我的ajax无效?

1 个答案:

答案 0 :(得分:0)

您可以尝试致电:

QWebSettings::globalSettings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls, true);

"Specifies whether locally loaded documents are allowed to access remote urls. This is disabled by default."