.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

"Failed to load source" posting to MVC2 action with jQuery

Posted By:      Posted Date: September 19, 2010    Points: 0   Category :ASP.Net


I am trying to save user feedback by using jquery to post to an action however i am getting the error message "Failed to load source for: http://www.something.com/feedback/savefeedback" this code works fine on localhost but not when put on my shared hosting, this doesnt just affect this query post but also at least one other.

below i have the route from the global.ascx, the action int the FeedBackController and the query that does the post.

"FeedBack",           // Route name
"FeedBack/{action}",  // URL with parameters
new { controller = "FeedBack", action = "SaveFeedBack", id = "" }  // Parameter defaults

 public bool SaveFeedBack(string FeedBack, string SubmitName, string email)

$.post("/FeedBack/SaveFeedBack", { FeedBack: feedbackText, SubmitName: SubmitName, email: email }, function(data) {

if (data == "True"){}

else {}


View Complete Post

More Related Resource Links

Posting data to ASMX and return Object for jQuery


I am using fluent NHibernate with WebForms and I am trying to build a page where I allow a user to post a status update on their profile page and I a using a .asmx WebService to post the data to the database and then returnig a StatusUpdate instance to the page to be used by jQuery. I have a couple problems.

1) First off when I return a string from the WebService(i was testing) the textbox where the user enters their status doesnt empty the contents. And since the page doesnt refresh even if I manally clear out the textbox and put in something else, it still posts the previous status to the database again. How do I fix this?

2) Secondly, when I return the StatusUpdate Object from the Webservice I cant the results to display anything. Like I sad, Im using jQuery to make an AJX call to the WebService.

Here is my code:

User Profile Page:

Status: <asp:Label ID="status" runat="server"></asp:Label><span style="font-size:.7em;"><asp:Label ID="statustime" runat="server"></asp:Label></span><br />
<textarea id="statusBox" rows="3" cols="40"></textarea><br />
<input type="button" value="Update Status" onclick="SetStatus(); return false;

Jquery Ajax Call to Mvc Action tips.


I try to do a ajax call via the jquery api.

The scritp :

$("#sortColumn").click(function(e) {
                var columnName = $(this).attr('name');
                var sidx = columnName;
                var sord = '<%= (string)ViewData["sord"] == "asc" ? "desc" : "asc"%>';
                var page = '<%= ViewData["page"] %>';
                var rows = "5";
                type: "POST",
                url: "/Mailings/GetData2",
                data: {'sidx': sidx ,'sord': sord ,'page': page ,'rows':  rows },
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(response) {
                var jsonObject = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
                error: function(xmlHttpRequest, textStatus, errorThrown) {
                    document.getElementById('infoContentHeader').innerHTML = xmlHttpRequest.responseText;


And the

jQuery modified ListBox not posting back modified values


Hi everyone,

I have an ASP.Net ListBox that I'm trying to populate via jQuery, using the following snippet:

        $("#MyList_btnAddAll").click(function(e) {
        $('#MyList_lstAll option').appendTo('#MyList_lstSelected');

The code has two ListBoxes in fact, one a "source" and the other a "destination".  As you can tell above the ListBoxes are MyList_lstAll and MyList_lstSelected.  These are rendered in the browser as <select> elements, as you'd expect.

The jQuery is working great, the items are moving from one ListBox to the other, the DOM is updated but when I submit this form (not using jQuery), the ListBoxes don't reflect this change on postback. 

I realize my modifications via jQuery aren't available in ViewState but I thought since the DOM was updated these changes would be part of the postback data?  But in the codebehind after postback the ListBox contents haven't changed.  Does anyone know what might be going on and what I can do about it?  Many thanks.

Populate Treeview upon entered criteria and page action without complete page posting on client side


1. I have a treeview on left side in a panel in my aspx page and I have a Text box and a Search button on the right panel. On entering a search criteria and clicking the Search button, I want to get the data needed for the treeview (FYI - I have a webservice call for that) and then populate the treeview completely but keep it collapsed to the root node.

  Each time I enter the search criteria and click the Search button, I don't want to post the entire page (and also don't like the page flicker), how can I achieve this? I know that in order to avoid complete postback upon Search button click, I can do so by client callback and get the data needed for the treeview, but in this case, I have to build the treeview nodes as table - row/cells and handle all the events and handlers myself, which I want to avoid (also means that I won't be able to take advantage of the inherent expand and collapse capabilities of the Treeview). On the other hand, if I use the OnTreeNodePopulate event handling of the Treeview control, using the C# script code on the aspx markup, it doesn't recognize the entered criteria in the Text box. So either way,

MVC2 client validation with jquery dialog


i am trying to get mvc2 client validation working with a jquery dialog, i have pretty much been using the mvc music store example at http://www.asp.net/mvc. if i go to http://localhost/Build/Edit/11, client validation works, but it will not work in the jquery dialog. any ideas?

ViewActive.aspx - main page with a link to popup a form


function showModalEdit(id) {

            var $loading = $('<img src="<%= Url.Content("~/Content/Images/ui-anim_basic_16x16.gif") %>" alt="loading"/>');

            var $dialogEdit = $('<div id="dialogEdit"></div>').append($loading.clone());



                height: 768,

                width: 1024,

                autoOpen: false,

                title: "Modify Build",


Run jQuery script after each form post in mvc2 app


I need to exec some js each time a page loads, and also every time a view is returned after a post action.  I use jQuery.ajax to post form - using url of Controller/Action.  Post is successful and response data is correct, but my js doesn't get called.

I had js in a script tag, within the head of my view.aspx, and found that it does not execute each time the response is received after a post action.  I also tried calling this within $(document).ready, but this does not execute after post action.  window.onload also does not exec after post action.

I prefer not to use MS AJAX js lib, but if there is some pageLoad function, I will give it a try.

Is there a native javascript event that is raised when http response is received?  Thanks.

ASP MVC2: wrong render of the model after posting


I have faced with some strange behavior and I hope you will be able to tell, what I do wrong.

My goal is to change the order of some object. This object has property Priority which defines the order. Objects render as a list and user can drag elements for prepare order. When user click save, JS code modifies Priority property in hidden fields in accordance with order of elements in the list. And this form is sent to the server.

My goal is to change the order of some object. This object has property Priority which defines the order. Objects render as a list and user can drag elements for prepare order. When user click save, JS code modifies Priority property in hidden fields in accordance with order of elements in the list. And this form is sent to the server.

Action get method in the controller:

public ActionResult EditPriority()
    return View(_missionRepository.OrderBy(mission => mission.Priority).ToList());

Action post method:


asp.net mvc2 upload file with jquery.form.js


developing website with  vs2010, asp.net4.0 , mvc2 ,jquery version 1.4.2.  I want to upload files with ajax, but the jquery scripts don't working. my code:


    <script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
    <script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
    <script src="/Scripts/jquery-1.4.2-vsdoc.js" type="text/javascript"></script>
    <script src="/Scripts/jquery-1.4.2.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.form.js" type="text/javascript"></script>

<form id="filePost" action="/Examination/Upload?examNo=<%:Model.ExamNo%>&medicalNo=<%:Model.MedicalNo%>"  method="post" enctype="multipart/form-data">
    <input type="file" name="FileUpload1" id="upFile" />
    <input type="submit" id="upload" value="upload" />

<div id="Details"></div>

<script lan

jQuery post to an action method



I hope this is the right section to post this, as it does seem to be an MVC related issue. I'm trying to use the jQuery.post() function to post an object to an action method, but for some reason the nested objects aren't initialised properly when they're received by the action method.

Here's my javascript code:

var data = {
    Id: 10,
    User: {
        Id: 5
$.post("/Home/SaveCompany", data, function (data) {

And my action method:

public ActionResult SaveCompany(Company company)
    if (company.Id > 0) {
    } else {
    return Json(new { id = company.Id });

company.Id has a value of 10, but company.User.Id is 0. Any ideas what I'm doing wrong? I've not named any properties incorrectly, by the way.


how to use jQuery to get MVC controller action?



I have this action on below

public ActionResult Edit(int id)

            var mtn0120 = __context.GetMtn0120(id);
            TempData["EditDateTime"] = mtn0120.EditDatetime;
            return View(mtn0120);

So how do I:

-use jquery $.get to access this action then redirect to the view?

-can I do it without using json?

-can I do it without modify the codes above?


GridView Confirmation Box Using JQuery BlockUI in asp.net

JQuery is the most popular JavaScript library. One of the main reasons for its fame is the plugin architecture. Anyone can create a separate library that leverage the JQuery library. In this article we are going to look at the BlockUI library which is used to block the user screen while performing a task.

jQuery $(document).ready() and ASP.NET Ajax asynchronous postback

Many call it the ASP.NET jQuery postback problem, but using the technique below should make it no problem anymore. $(document).ready() isn't called after an asynchronous postback. What this means? You lose the functionality that should be executed within $(document).ready() after an UpdatePanel rendered its contents after an asynchronous postback.

call JavaScript - jQuery code from ASP.NET Server-Side

jQuery got so close to me lately that I can see myself adding the scripts to my project almost unconsciously. The thing is, jQuery is very useful for me, in almost all situations and it has been a do or die enhancement for all my project since I first put my hands on it.

Of course while using it, you encounter few situations which need a bit of research to solve, mostly when you are trying to combine it with some other technologies like: UpdatePanels and ASP.NET Ajax. For instance there are many situations when I would like to run some jQuery magic based on some decision that I make on the server side.

Making Ajax Callbacks to the Server Using jQuery with ASP.NET

In the first part of this article series I introduced jQuery's functionality and how it provides a rich client side programming model. This time around I'll expand on these concepts and show you how you can use jQuery in combination with ASP.NET using it as an AJAX backend to retrieve data. I'll also discuss how you can create ASP.NET controls and otherwise interact with jQuery content from ASP.NET pages in WebForms.

jQuery is just a JavaScript library so it will work seamlessly with ASP.NET both from page code as well as through backend driven code using the Page.ClientScript object or ScriptManager. You can use jQuery on its own as a client side and Ajax library that communicates with ASP.NET or you can use jQuery in combination with ASP.NET AJAX. The two actually complement each other quite well as jQuery provides functionality that the ASP.NET AJAX library does not and vice versa. For the most part the interaction between the two libraries is trouble free except for a few very rare edge cases.

Displaying Row Details Tooltip on GridView using JQuery

Continuing exploring JQuery! I decided to implement a feature to display some kind of details related to a row displayed on GridView. For example when displaying employees details on GridView some information might not fit in the GridView because it will make it huge and wide. These infomration can be diplayed as Tooltip. Or when you want to display a picture and some kind of formated text to be diplayed as tooltip when mouse hover on the image.

jQuery: Highlight Gridview Rows with Checkbox

Im learning and experimenting with jQuery and ASP.NET. Below is a simple solution I created to highlight rows in a gridview by clicking on a checkbox next to the row.

Gridview setup:

Using jQuery with ASP .NET

With that, JQuery is officially embraced by ASP.NET.

A brief introduction of JQuery

jQuery is the star among the growing list of JavaScript libraries. A few of its characteristics are light-weight, cross-browser compatibility and simplicity. A common task that sometimes takes 10 lines of code with traditional JavaScript can be accomplished with jQuery in just one line of code. For example, if you want to dress up a table with an ID mytable with alternative color for every other row, you can simple do this in jQuery.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend