开发者

gif does not display in jquery AjaxForm

i am trying to display an image during my ajax call. I am using the jqueryform plugin. i cant seem to get the path right: i need the root path ,here is my code:

 $(function () {
                $("#ajaxUploadForm").ajaxForm({
                    iframe: true,
                    dataType: "json",
                    beforeSubmit: function () {
                        $("#ajaxUploadForm").block({ message: '<img src=' + '<%= @Url.Content("/Content/busy.gif") %>' + '/> Uploading Document...' });
                    },
                    succe开发者_Go百科ss: function (result) {
                        $("#ajaxUploadForm").unblock();
                        $("#ajaxUploadForm").resetForm();
                        //$.growlUI(null, result.message);
                        if (result.message != 'Success') {
                            alert(result.message);
                        }
                        else {

                        }
                    },
                    error: function (xhr, textStatus, errorThrown) {
                        $("#ajaxUploadForm").unblock();
                        $("#ajaxUploadForm").resetForm();

                    }
                });
            });


Try like this:

$('#ajaxUploadForm').block({ 
    message: '<img src="<%= Url.Content("~/Content/busy.gif") %>" /> Uploading Document...' 
});

Be careful though as if this is in a separate javascript file you will not be able to use helpers such as Url.Content. Another possibility is to use CSS:

$('#ajaxUploadForm').block({ 
    message: '<div class="spinner">Uploading Document...</div>' 
});

and in your CSS file you could use relative paths (relative to the location of the CSS). Thus if you have a ~/Content/site.css file you could define the following rule:

.spinner {
    background-image: url('busy.gif');
    width: 20px;
    height: 20px;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜