How To Get Current Page Path In JQuery (while Doing Ajax Call)
Aug 18, 2010
I am doing Ajax call using jQuery and my URL is like
http://localhost;3327/DummyAps/Demo.aspx
In Demo.aspx page i have a WebMethod, which i wanted to call. While doing jQuery ajax call i am giving the URL as "/DemoWebMethod", where "DemoWebMethod" is the Webmethod present in Demo.aspx page.
But while calling the WebMethod it is calling the URL
http://localhost;3327/DummyAps/DemoWebMethod but i want to call
http://localhost;3327/DummyAps/Demo.aspx/DemoWebMethod.
I know that changing the URL from "/DemoWebMethod" to "Demo.aspx/DemoWebMethod" will solve the problem but can i do it without writing that (because i have some problem with that).
1- I have an Ajax link that call an action and that action returns a view , that view open in a specific Div (consider it as a menu that update the div with the corresponding view) 2- if session timeout the returned my logon view so if i click on the link and session is timeout , the log on view open in the div not in the whole page
what i should do so if the session timeout it return logon view in new page in on my div?
Am I missing something? I'm trying to do a simple ajax call using jquery to a web service on my site and I get a 500 error every time when I make the call from the master page. Has no one ever made an ajax call from a master page or am I just crazy and extremely deprived of sleep?Example:
i want to know that from which pages my current page has been called in ASP.net As for example I want the track of page named "hero.aspx" and it has been called from "Zero.aspx" and "Zero.aspx" has been called from "one.aspx" So i want output as whole page called hierarchy.How can i get this in asp.net
To get the url of the current page, I usually do something like this:string path = Request.Path;If I do this after a Server.Transfer then I get the path of the page where the transfer was done. How can I get it for the current page?For example:
On Page1.aspx I do Server.Transfer ("Page2.aspx") On Page2.aspx Request.Path returns /Page1.aspx and not /Page2.aspx
I have a page where the user will select criteria from drodownlists and then click the "go" button.I would like to create some kind of progress template or progress-bar so that the user will know that the query is in progress. What are the best and easiest options for this?I just want a simple thing like a rotating sand clock,
I am developing web application and in application i need to make call of jQuery using .ajax(); method with datatype is set jsonp. Now all works well with limited data but problem start to occur when data size is increasing......
which returns <div>here</div><script language=javascript>alert('');</script> The content gets loaded property, but no alert. How would I get a javascript routine to work from an ajax call along with posting the HTML code?
Scenario is I have a application relative url like "~/path/to/page.aspx?query=string". I need to programatically create a web request to that page and currently using WebRequest.Create. The problem is WebRequest.Create requires a fully qualified url including the protocol/domain/port etc.I have access to the current Request.Url object but there doesn't seem to be an easy way to get just the base url keeping the protocol (HTTP vs HTTPS) as well as any port numbers as well as the path to the applicationI mean all the info there, so if need be I could just take all the parts and combine them but it seems like it might be error prone and it would be great to have something built-in that's well tested to do the job. Page.ResolveUrl gets me almost there, but it's missing the protocol and the domain/port.
I need to perform asp.net web-service function call via jQuery and pass asp.net application path to it. That's the way I'm trying to do it (code is located within asp.net page, e.g. aspx file):
[code]...
Function call works well, but applicationPath parameter doesn't passed correctly. When I debug it I see that backslashes are removed, function gets "C:ProjectsSamplesmytestwebsite" instead of "'C:ProjectsSamplesmytestwebsite'".
Its time for another very simple question that I can't find an elegant solution for. Basically, I have an app that is using a jQuery Ajax call. In this call, you have to specify a URL path for the service that you are calling. In this instance, I am needing to call this JavaScript function from multiple files in my application and those files are on differing levels of the folder structure.
Here's the question, how would you elegantly handle this scenario so that you can call the JS function from any location in your app. Here are my constraints:
1) I am running on Asp.Net 4.0. 2) My current environment has a local, Dev, Test, and Prod Environment (hard-coding the URL path will not work).
I'm sorting a gridview inside an update panel. When the user clicks on the column header, the gridview resorts itself fine. However, after the sort, I' like to run a javascript function called MyScript.
I have a page called AddNews.aspx and in codebehind a web method called AddNews(Parameters).. AddNews.aspx page is inherited from a master page.. So i used contentplaceholder. I have a button..It's id is btnSave.
[ServiceContract(Namespace = "")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class Aja { [WebGet] [OperationContract] public string Hi() { return "hi world!"; } }
and I'm trying to do this: $.get('Aja.svc?method=Hi', function(d) { alert(d.d); }); In firebug I see that the result is HTTP Error 404.17 - Not Found The requested content appears to be script and will not be served by the static file handler. I use .net 3.5, jquery 1.4.4
I created a number of standard WCF Services (Service Contract and Host (svc) are in separate assemblies). I fired up a Web Site in IIS to host the Services (i.e., address is [URL]). Then in my Web Site project I added the reference. I am able to call the services normally. I am needed to call some of the services client side. Not sure if I should be looking at articles calling WCF services through AJAX, JQuery, or JSON enabled WCF Services. Some of the changes I made was adding the following to the Operation Contract:
I am attempting to call the service like this in javascript: wcfservices.SetFoo(string Id); Nothing is working. If it is idea or a better solution to call JSON enable, JQuery, etc.... I am willing to make any changes.
If you visit this [URL] and then click on the link like the image below you'll see in-line pop-up DIV which displays a busy status of Ajax callback before it displays the information. So, the information is not there yet until you click on the link.
I have a requirement where i need to show the list of data in a jquery dialog once a some link is clicked .I can easily collect the data that has to be shown in the dialog on page load and display the data in the dialog.I will place those data in a hidden div and simply pop it up when the user clicks on the link.But my requirement is that there has to be jquery ajax get when the users clicks on the link and that content should be displayed in the jquery dialog.How can i achieve that.
i have a jquery .click() function that executes an .ajax() method call
[Code]....
when the .ajax() method executes succesfully it calls a javascript function
[Code]....
as you can see i have an .ajax() method inside my javascript function, is this possible? I am creating loop that starts on the finish listener of the soundmanager object. So when I need to make the ajax call to get he next url I need.
I have the following jQuery event that gets fired every time an anchor is clicked. How can I pass a asp.net control (lets say a panel called "pnl_info") as one of the parameters, in addition to the "target" parameter i'm already passing?
Let say I got the following button : <asp:Button ID="btnSearch" runat="server" /> and the following button event handler: Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSearch.Click ow, with JQuery, can I call the button event handler ? What I mean is that I don't want the page to refresh, so it's kind of Ajax call. I don't want to simulate the click but that on click the button event handler is call.
From client side, I need to call a server method that is not static. For example, I got the following user control ucData (private instance of code-behind) that is Databind in the load event. The server method I need should return ucData.IsValid(). So it can't be static
I am new to jqGrid and I have found it difficult to follow the documentation jqGrid Documentation / I cannot figure out how to call a WebMethod when setting up the JQGrid. I have been successful in making an Ajax call to get the data and then setting up the JQGrid with local data. I think its an extra step in the setup process and that I should be able to provide the path to the webmethod using the url property. The editurl property is the same way. I am never actually receiving the post to the server. Attempted JQGrid Setup
function GetData() { $('#list').jqGrid({ type: "POST", url: "Default.aspx/GetUsersJSON", datatype: "json", height: 250, colName: ['Username', 'Email'], colModel: [ ... }).jqGrid( 'navGrid', '#pager', { edit: true, add: true, del: true }); } WebMethod [WebMethod] public static string GetUsersJSON() { var users = new List(); using(UserAdministrationSandboxDataContext uasd = new UserAdministrationSandboxDataContext()) { users = uasd.GetUserList(); } JavaScriptSerializer serializer = new JavaScriptSerializer(); return serializer.Serialize(users); }
Current Code I got it working correctly now, but I still have one final question. Why did I have to set the 'repeatitems: false' in order to display the content? Some of the caveats to get this to work include the different ways to setup the ajax request. (Ajax: type) is (jqgrid : mtype) (Ajax: contentType) is (jqgrid : ajaxGridOptions: { contentType: })
And finally understanding the documentation from the documentation on how to setup the JSONReader.
function GetUserDataFromServer() { $('#list').jqGrid({ url: "Default.aspx/GetUsersJSON", mtype: 'POST', ajaxGridOptions: { contentType: "application/json" }, datatype: "json", serializeGridData: function (postData) { return JSON.stringify(postData); }, jsonReader: { root: function (obj) { return obj.d; }, page: function (obj) { return 1; }, total: function (obj) { return 1; }, records: function (obj) { return obj.d.length; }, id:'0', cell:'', repeatitems: false }, datatype: "json", height: 250, colName: ['Username', 'Email'], colModel: [ { name: 'Username', index: 'Username', width: 100, editable: true }, { name: 'Email', index: 'Email', width: 220, editable: true }, { name: 'IsLockedOut', index: 'IsLockedOut', width: 100, editable: true, edittype: 'checkbox' } ], caption: "Users" }) } Web Method [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public static List GetUsersJSON() { using (UserAdministrationSandboxDataContext uasd = new UserAdministrationSandboxDataContext()) { return uasd.GetUserList(); } } One JSON Object from the List {"__type":"UserAdministrationSandbox.UserData","PKID":"00000000-0000-0000-0000-000000000001","Username":"TestUser","ApplicationName":"Test","Email":"TestUser@test.com","Comment":"TestUser","Password":"D41D8CD98F00B204E9800998ECF8427E","PasswordQuestion":"Is this a blank Password?","PasswordAnswer":null,"IsApproved":true,"LastActivityDate":"/Date(1298869200000)/","LastLoginDate":"/Date(1298869200000)/","LastPasswordChangedDate":"/Date(1298869200000)/","CreationDate":"/Date(1298869200000)/","IsOnLine":false,"IsLockedOut":false,"LastLockedOutDate":"/Date(1298869200000)/","FailedPasswordAttemptCount":0,"FailedPasswordAttemptWindowStart":null,"FailedPasswordAnswerAttemptCount":null,"FailedPasswordAnswerAttemptWindowStart":null}
I'm pretty much completely new to MVC - I've been playing around with some features for a few months and I'm currently implementing a simple administration panel for a website. I'm a very experienced developer, but the interaction between MVC views and javascript is confusing me a little bit. Here's my scenario:
I have a stored procedure that runs periodically via an agent job in MSSQL. The stored procedure synchronises data from an internal database - it can sometimes (depending on network demand and the amount of data) take a minute or two to run.I'm using LINQ to SQL as my data model.I need to be able to call the Stored Procedure on demand via the click of a button. This "works" if I call it within the code, but obviously I would prefer to make an async call via AJAX after clicking the button, so I can display an "Executing" image or indeterminate progress bar.
At the moment I have the following code in my Controller:
[Code]....
And the following code in my View (Razor syntax):
[Code]....
Which works perfectly fine. However, my brain isn't working this morning, and I'm struggling to figure out how to implement an AJAX call using the integrated JQuery classes?