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

  • Home
  • SEARCH
  • 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 6939269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:36:04+00:00 2026-05-27T12:36:04+00:00

I think the problem is with jQuery, i don’t know for sure. Let me

  • 0

I think the problem is with jQuery, i don’t know for sure.

Let me explain the situation.

Screenshot 1

I fill in the partialView and click on submit.

The submit is a jQuery event handler with the following code:

_CreateOrEdit.cshtml

<script type="text/javascript">
$(document).ready(function () {

    $('input[type=text], input[type=password], input[type=url], input[type=email], input[type=number], textarea', '.form').iTextClear();
    $("input:checkbox,input:radio,select,input:file").uniform();
    $("input[type=date]").dateinput();


});
$(window).bind('drilldown', function () {
    $(".tabs > ul").tabs("section > section");
});
$("#CreateOrEditSubmit").submit(function () {
    //get the form
    var f = $("#CreateOrEditSubmit");
    //get the action
    var action = f.attr("action");
    //get the serialized data
    var serializedForm = f.serialize();
                $.post(action, serializedForm, function (data) {
                    $("#main-content").html(data);
                });
    return false;

});
</script>

This all works fine on the first-run.

Then when i submit the form when it is invalid (Screenshot 1),

        [HttpPost]
    public ActionResult Create(Client client)
    {

        if (ModelState.IsValid)
        {
            context.Clients.Add(client);
            context.SaveChanges();
            return RedirectToAction("Index");  
        }

        return PartialView(client);
    }

Then it tries to redisplay the same form again (Controller Client, Action Create), but something isn’t triggered right (Screenshot 2). The layout is wrong (buttons still hidden), the tabs aren’t working (javascript), …

Worst of all, i don’t get any error in Firebug, Chrome Console, …

Does anyone have an idea what could be the problem, because i really haven’t got a clue what’s happening. It seems to me that nothing has changed, but it did :s

Fyi, an equivalant for the post function is :

 var request = $.ajax({
        type: 'POST',
        url: action,
        data: serializedForm,
        success: function (data) {
            $("#main-content").html(data);
        },
        dataType: 'HTML'
    });

    request.done(function (msg) {
        $("#log").html(msg);
    });

    request.fail(function (jqXHR, textStatus) {
        alert("Request failed: " + textStatus);
    });

Screenshot 1
Screenshot 2

Before submit, everything loads fine

After submit, same form is called. jQuery isn’t working anymore and form is getting bricked (i think this is “side” behaviour from the jQuery breaking)

Edit: (on request)
Here is the partialView in full

_CreateOrEdit.cshtml doesn’t contain any javascript for now, the result is the same, so i only posted Create.cshtml.

Create.shtml

@model BillingSoftwareOnline.Domain.Entities.Client

<div class="container_12 clearfix leading">
<div class="grid_12">
    @using (Html.BeginForm("Create", "Client", FormMethod.Post, new { @class="form has-validation", id="CreateOrEditSubmit"}))
    {

        @Html.Partial("_CreateOrEdit", Model)

        <div class="form-action clearfix">
            <button class="button" type="submit">
                OK</button>
            <button class="button" type="reset">
                Reset</button>
        </div>
    }
</div>
</div>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.itextclear.js")">    </script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.uniform.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.tools.min.js")">    </script>



<script type="text/javascript">
$(document).ready(function () {

    $('input[type=text], input[type=password], input[type=url], input[type=email],     input[type=number], textarea', '.form').iTextClear();
    $("input:checkbox,input:radio,select,input:file").uniform();
    $("input[type=date]").dateinput();


});
$(window).bind('drilldown', function () {
    $(".tabs > ul").tabs("section > section");
});
$("#CreateOrEditSubmit").submit(function () {
    //get the form
    var f = $("#CreateOrEditSubmit");
    //get the action
    var action = f.attr("action");
    //get the serialized data
    var serializedForm = f.serialize();
    //                $.post(action, serializedForm, function (data) {
    //                    $("#main-content").html(data);
    //                });
    var request = $.ajax({
        type: 'POST',
        url: action,
        data: serializedForm,
        success: function (data) {
            $("#main-content").html(data);
        },
        dataType: 'HTML'
    });
    return false;

    request.done(function (msg) {
        alert(msg);
    });

    request.fail(function (jqXHR, textStatus) {
        alert("Request failed: " + textStatus);
    });



});

</script>
  • 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-05-27T12:36:05+00:00Added an answer on May 27, 2026 at 12:36 pm

    Since this markup is returned as a partial, you need to reinitialize your javascript.

    This is hacky, but try putting your script in the partial view, instead of _CreateOrEdit.cshtml, and see if that works.

    Update

    After seeing the cshtml, it looks like it is not working because $(document).ready() has already executed, before the ajax load. Try this instead:

    $(function () {
        $('input[type=text], input[type=password], input[type=url], input[type=email], input[type=number], textarea', '.form').iTextClear();
        $("input:checkbox,input:radio,select,input:file").uniform();
        $("input[type=date]").dateinput();
    
        $(window).bind('drilldown', function () {
            $(".tabs > ul").tabs("section > section");
        });
       $("#CreateOrEditSubmit").submit(function () {
            //get the form
            var f = $("#CreateOrEditSubmit");
            //get the action
            var action = f.attr("action");
            //get the serialized data
            var serializedForm = f.serialize();
            //                $.post(action, serializedForm, function (data) {
            //                    $("#main-content").html(data);
            //                });
            var request = $.ajax({
                type: 'POST',
                url: action,
                data: serializedForm,
                success: function (data) {
                    $("#main-content").html(data);
                },
                dataType: 'HTML'
            });
            return false;
    
            request.done(function (msg) {
                alert(msg);
            });
    
            request.fail(function (jqXHR, textStatus) {
                alert("Request failed: " + textStatus);
            });
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple problem (I think): I want to be able to invoke a click method
I'm fairly new to JQuery and Javascript in general. I don't think I'm trying
I'm having problems with selectors in jQuery. Or (what I don't think) with my
I have a problem with jquery and a dynamic table. I want a click
I don't think my question is difficult but I'm just a newbie in jQuery
The problem I think is with returning an object when i overload the +
I think that this problem can be sorted using reflection (a technology which I'm
My problem is one that you would think is quite common, but I haven't
I think I have a problem in understanding the proper way of using MVC.
I think I have a synchronization problem...It may be too basic..Please help.. I have

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.