So there is a 3rd party ajax call that takes ~5 mins for every request. So when debuggin on local machine, is there a way to simulate that ajax call like maybe store the response somewhere and load that as response every time that call is made to make debugging quicker.
I tried looking at the chrome inspector tool there is a way to resubmit an earlier ajax call, but I need the whole page load execution cycle so thats no use. There is also a way to save the response / or block the URL but no way to simulate/side load the ajax call with a local response saved in maybe a json file or something.
TlDR; Just like there is a way to block a certain URL, Is there a way to specify a certain URL to load local data insted of making the call to the endpoint.
I know software solutions are offtopic for SO, but since this question was unanswered for quite some time, and this functionality is not implemented yet in an browser, so here it goes.
I came across the Chrome Extension named : Mokku: Mock API calls seamlessly
This does seem to fulfil the expectations set.
Related
How can I decide if a website is using Ajax technology? What are the characteristics that I should I look in the website to tell it is an ajax application?
Search the javascript for XMLHttpRequest. Beyond that, the working definition of Ajax is rather too broad to look for, say, specific behaviours.
You can just look into the javascript source code and search for .ajax, .post and .get . If you find any of these they use ajax technologies.
You can also look at the network requests a page sends, if the page sends requests after loading the full page without you seeing it refreshing it probably uses ajax.
There's nothing special about websites using AJAX, it just means they make an asynchronous call to the server at some point. You can't know for certain that the website will make such a call unless you run it.
I'm doing a project which ,obviously, uses Ajax to handle lots of requests from User Interface. Once of which is to "Filter" the given list of users. I'm using it with Laravel at back end.
So the scenario is that when I filter users by their company it works perfectly, but when I filter users by locations, it shows all the users from all locations instead of chosen location which means all the location ids are being passed. Code is written by some one else. I don't know where to fix it. So I want to know that Chrome supports some good tools to handle and debug Ajax request but don't know how to do that. Can some one plz suggest me the right way to handle, debug and explore the call backs of Aajx request so I could also save my time????????????
You can use the google chrome devTools console and go to the Network menu. It works great.
If you want more you can use Charles
Currently, Fine Uploader uses a POST to send the data to the server - is there a way to change this to a PUT in the options object? I'm using backbone.js, and a POST makes a new record, and a PUT triggers an update.
Thanks.
POST is the most appropriate method for an upload request, mostly because file upload requests are intended to be idempotent. PUT request are more appropriate for non-idempotent (update) requests.
However, there is another reason why PUT is not a good choice here: this will not work in IE9 and older. In those browsers, a form is submitted inside of a hidden iframe for each file to be uploaded, due to lack of File API support. There are only two valid values for the method attribute on a <form>: GET and POST. So you'd have to handle POST requests anyway, unless you are not going to support IE9 and older (not likely).
I am familiar with backbone.js, and there is no reason why POST requests cannot be used, especially in this instance. You haven't provided any specific reason why PUT requests are preferable here, so I can only assume that if there is such a requirement, this is likely due to some logic in your application that should probably be re-evaluated.
I have an ASP.NET MVC web page that has a file upload control. Under rare conditions the file referenced by the user moves or is deleted on the filesystem prior to the user triggering the post to the page. In IE9 the page successfully posts but the ContentLength is zero (expected) and can be handled server-side. However in Firefox I find that the POST action never reaches the server.
Is there anyway to detect that the file reference is still valid prior to posting the page? Or a way to detect that an error occurred client-side during the POST due to the moved/deleted file?
Using just input type="file", you have no access to check whether the file actually exists until an upload attempt is made. There are some emerging functionalities like FileReader which may help as browsers mature (as it's not available in all browsers) that should make the upload process far smoother (and will make detection of this situation more simple).
If you use an Ajax style upload process, you could initiate the upload right away to help prevent the issue from occurring in the first place.
Or, a bit hacky: one idea for Firefox would be to add a setTimeout in the onsubmit event that fires after a second ... and checks to see if the upload started (by querying the server using Ajax to a JsonResult action/function that can quickly see if an upload started, etc.). It's a bit messy though as you'll need to worry about timing issues -- and may be overkill just to handle the cases where this is occurring.
i have two servers a main site and a static server.
i want to get a file's content from ajax in runtime, which is stored in static server.
obviously cross domain problem will occur.
so what i am trying to do is storing that ajax .js in the static server, so that calling the local file wont be a problem.
but after i include that js file from static, still that problem remains...
Any solutions?!
n't use X domain Ajax Requests. Create a "proxy" on your own server (domain) then forward the call to the other domain, cache it, check for security issues and send it back to client again...
Depending on the information you want your ajax request to recieve you could always use something like jsonp which could have the cross-site call.
try looking here for some examples:
http://remysharp.com/2007/10/08/what-is-jsonp/
Take a look at EasyXDM. It's a library which wraps cross-browser quirks and provides an easy-to-use API for communicating in client script between different domains using the best available mechanism for that browser (e.g. postMessage if available, other mechanisms if not).
Caveat: you need to have control over both domains in order to make it work (where "control" means you can place static files on both of them). But you don't need any server-side code changes.