简体   繁体   中英

How to display the message in the popup?

i have a popup that was designed in a html page. 在此处输入图片说明

i need to show the message "This batch contains " + TargetCount+ " records. Please press Continue to finish importing your data.", near the buttons outside the border,where the "TargetCount" returns from controller. I have my controller like,

   [HttpPost]
   public JsonResult UploadFile(string id)
   {
   if (this.Request.Files.Count >= 1)
        {
            var file = Request.Files[0];
   ImportFileSetting importFileData = importHandler.SaveUploadedFile(file, caseNumber, isFieldName);
        return Json(importFileData.TargetCount);
        }
        return Json(null);
    }

and i have my jquery like,

function UploadFile(event) {
sendFile(event.target.files[0]);}
function sendFile(file) {
var data = new FormData();
data.append("Uploaded", file);
var id =true;
$.ajax({
    type: 'post',
    url: '/Import/UploadFile?id=' + id,
    data: data,
    success: function (data)
    {
        if (data) {
            var errorMessageOne = " This batch contains " + data + " records.  Please press Continue to finish importing your data.";
            return errorMessageOne;
        }

    },
});}

As iam the beginner i dont how to return this message. Kindly tell me how to achieve this.

$.ajax({
type: 'post',
url: '/Import/UploadFile?id=' + id,
data: data,
success: function (data)
{
    if (data) {
        var errorMessageOne = " This batch contains " + data + " records.  Please press Continue to finish importing your data.";
        <!-- example code -->
        $('.msgbox').html(errorMessageOne);
    }

},
});

I've taken your ajax code and edited as above! You don't have to return the msg! just take the element you want to show the message and add the var element in it's html as I've shown in the example! Since my code is an example you would need to look a bit into jquery and select your necessary element to show the message.

for an example if you have a h1 tag with a class message the code should look as following.

$('.message').html(errorMessageOne);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM