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 7017063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:51:58+00:00 2026-05-27T22:51:58+00:00

I am working on mvc project in razor.In this i am working on import

  • 0

I am working on mvc project in razor.In this i am working on import and export module.
Now in my action i am returning JSON object.Now in both Http Get Request or Http Post request i am getting the same problem.Because the breakpoint is hitting twice,my record get added in database twice.

Below is my script

<script type="text/javascript">
    $(document).ready(function (e) {
        $(".update").live('click', function () {
            var id = $(this).attr('id');
            var str = "";
            $(this).parent('td').parent('tr').find('td.data').each(function () {
                str = str + ";" + $(this).text().trim();
            });
            if (str.length > 0) {
                str = str.substring(1, str.length);
            }
            var header = $("#hdn_header").val();
            $.post('/ImportCSV/Update', {
                ImportData: str,
                ImportHeader: header
            }, function (result) {
                var CompName = result.CompanyName;
                var CompPhone = result.CompanyPhone;
                var CompEmail = result.CompanyEmail;
                var CompWebsite = result.CompanyWebsite;
                var CompAddress = result.CompanyAddress;
                var CompZip = result.CompanyZip;
                var CompCity = result.CompanyCity;
                var CompCountry = result.CompanyCountry;
                var CompNote = result.CompanyNote;
                var ConFirstName = result.ConFirstName;
                var ConLastName = result.ConLastName;
                var ConTitle = result.ConTitle;
                var ConPhone = result.ConPhone;
                var ConEmail = result.ConEmail;
                var ConNote = result.ConNote;
                var ConMobile = result.ConMobile;
                $(".update").each(function () {
                    if ($(this).attr('id') == id) {
                        var i = parseInt('1');
                        $(this).parent('td').parent('tr').find('td.data').each(function () {
                            if ($(this).text().trim() != CompName && $(this).index() == 2) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != CompPhone && $(this).index() == 3) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != CompEmail && $(this).index() == 4) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != CompWebsite && $(this).index() == 5) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != CompAddress && $(this).index() == 6) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != CompZip && $(this).index() == 7) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != CompCity && $(this).index() == 8) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != CompCountry && $(this).index() == 9) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != CompNote && $(this).index() == 10) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != ConFirstName && $(this).index() == 12) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != ConLastName && $(this).index() == 13) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != ConTitle && $(this).index() == 14) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != ConPhone && $(this).index() == 15) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != ConMobile && $(this).index() == 16) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != ConEmail && $(this).index() == 17) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                            if ($(this).text().trim() != ConNote && $(this).index() == 18) {
                                {
                                    $(this).css('backgroundColor', '#FFFFC0');
                                    return;
                                }
                            }
                        });
                    }
                });
            });
            return false;
        });
    });
</script>

The above is my whole script and again it is giving same error.pls check and let me know if i am doing wrong.
Thank you..

  • 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-27T22:51:59+00:00Added an answer on May 27, 2026 at 10:51 pm

    It is not very clear where exactly are you invoking this AJAX request but I suspect that it is inside the .click event of some anchor or a .submit button and you didn’t cancel the default action of this button by returning false from the handler. So when the link is clicked you get a first request with the AJAX POST and immediately after the default action of the link is executed.

    So for example if you were subscribing to the .submit event of some form try canceling the default action by returning false:

    $(function() {
        $('#someForm').submit(function() {
            $.post('/ImportCSV/Update', { ImportData: str, ImportHeader: header }, function (result) {
                var CompName = result.CompanyName;
            });
    
            return false; // <-- that's the important part
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on mvc project, with repository pattern and entity framework, now on
I am lost on this MVC project I am working on. I also read
I have a mvc 3 razor project that on pc is working very good
have everything working fine with mvc.razor generator. Views from my library project show up
I am working on this mvc project following Rob Connery's storefront video series and
I am working on my 1st mvc razor project. I set the project and
I am working on project using MVC 3.0(Razor framework). I am trying to get
I am working on a mvc project, and having problem with json. i have
I'm working with the System.Web.Helpers.WebGrid in an ASP.NET MVC 3 Razor project, and I'm
I've been working on an ASP.NET MVC project for about 8 months now. For

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.