Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7992727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:39:03+00:00 2026-06-04T13:39:03+00:00

View: @{ AjaxOptions ajax = new AjaxOptions() { HttpMethod = POST, UpdateTargetId = sub_id

  • 0

View:

@{
    AjaxOptions ajax = new AjaxOptions() { HttpMethod = "POST", UpdateTargetId = "sub_id" };
    Layout = null;       
}

<div id="sub_id"></div>

@using (Ajax.BeginForm(ajax))
{
    @Html.TextBox("email");
    <input type="submit" value="подписаться" />
}

controller:

[HttpPost]
public ContentResult LeftMenuSubscription(string email)
{
    return new ContentResult(){Content = "<script>alert('Thanks')</script>"};
}

“Thanks” alert show.

but in div sub_id set all page(<title></title><div>...</div>).

<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script> 

– connected.

html:

<html>
    <head>
        <title>Главная страница</title>
        <link href="/Content/Site.css" rel="stylesheet" type="text/css">
        <script src="/Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
        <script src="/Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"</script>
        <script src="/Scripts/jquery.validate.min.js" type="text/javascript"></script>
        <script src="/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
        <script src="/Scripts/jQueryFixes.js" type="text/javascript"></script>
    </head>
    <body>
        ....
        <form action="/" data-ajax="true" data-ajax-method="POST" data-ajax-mode="replace" data-ajax-update="#sub_id" id="form0" method="post">
            <input id="email" name="email" type="text" value="">
            <input type="submit" value="подписаться">
        </form>
        ....
    </body>
</html>

What could be the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:39:04+00:00Added an answer on June 4, 2026 at 1:39 pm

    Looks to me like your Ajax options aren’t complete. I believe you need to add the Action that you are requesting from:

    @using (Ajax.BeginForm("ActionName", "ControllerName", ajax))
    {
        @Html.TextBox("email");
        <input type="submit" value="подписаться" />
    }
    

    Running this in a test I get a popup alert, which is exactly what should happen because you are returning a script that says: <script>alert('Thanks')</script>

    If you just want the div to show Thanks then don’t return the script tag

    Use this if you just want to have the word thanks show up in the div

    [HttpPost]
    public ContentResult Test(string email) 
        return new ContentResult() { Content = "<span>Thanks</span>" };
    }
    

    This works perfect for me using the modified form

    @using (Ajax.BeginForm("Test", "Test", ajax))
    {
        @Html.TextBox("email");
        <input type="submit" value="Save" />
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following view:- <div id = partialWrapper> @using (Ajax.BeginForm(Create, Answer, new AjaxOptions
View <%= Ajax.ActionLink(Create, Create, ViewData.Model, new AjaxOptions { HttpMethod = POST })%> <%= Html.ValidationSummary(Create
i have view which looks something like this : <% using (Ajax.BeginForm(new AjaxOptions {
My view <div id=ValidationSummary> @Html.Partial(ValidationSummary) </div> @using (Ajax.BeginForm(Index, //<-- Action name JobDetails, //<-- Controller
Using the following form in a view <% using (Ajax.BeginForm(PatientSearch, new {}, new AjaxOptions()
This is the code in my partial view - @using (Ajax.BeginForm(SaveLayout, new AjaxOptions {
i have a jquery Dialog in a partial view: @model JQueryDialogPoc.Models.FeedBack @using (Ajax.BeginForm(GiveFeedback, Home,
If I have a textbox in my view: <div><%= Html.TextBox(Comments, Model.Comments)%></div> I want to
I have a simple form created using Ajax.BeginForm : <% using (Ajax.BeginForm(Update, Description, new
In the following code, I'm using Ajax.BeginForm to post data to the action asynchronously.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.