How can I initiate Ajax request from firefox developer tools? - javascript

I want to test several Ajax requests after the backend code completed. Now my method is adding a dummy button, an onclick event and an ajax request inside that.
Is there any way I can initiate Ajax request for testing from firefox-developer-tools without editing my jsp / frontend?

You can use Scratchpad, Firefox's dedicated tool for executing JavaScript.
From docs:
Unlike the Web Console, which is designed for interpreting a single line of code at a time, Scratchpad lets you edit larger chunks of JavaScript code, then execute it in various ways depending on how you want to use the output.
Just open up Firefox and hit Shift+F4 and you are good to go. using Ctrl+R you can run your code (whole code or selected parts)
BTW you can have Scratchpad as a tab in dev tools, of course it's not enabled by default, but you can enable that via dev tool options.

Related

HTML file call to calculation function

This is my first time delving into an HTML editor with goal of learning it. I opened the website option-price.com and right clicked in chrome to get the source.
I am not able to figure where the real calculation happens when I hit the button Calculate.
Mostly such content is embedded.like most of the web pages don't allow you to see the source code.
But
Firebug is a discontinued free and open-source web browser extension for Mozilla Firefox that facilitated the live debugging, editing, and monitoring of any website's CSS, HTML, DOM, XHR, and JavaScript.
You need to open the console (option + cmd + J on Mac and Chromium), and not the source.
Then you might want to look at the Sources tab, and try and find the Javascript (file or from the HTML (here index.php) responsible for what you want to debug. However it seems for this very site that the Calculate does a server call to do the calculation.
Such calculations would not typically be on the front-end - they would likely be happening on whatever back-end they are using (ex. PHP, Django, etc.) by making a server call, which is definitely not displayed in the source.

how to stop modification and changes in client side source file in developer tool?

I am using angular in i can easily add some javascript code and modify the program. Is there any way to stop modification in source file?
You can use the Uglify and Minify methods to make changes difficult, but never stop them.
Its Developer Feature provided in browser to do client side modification for testing purposes.
you dont worry it wont modify your source code anyhow.. its just for some time till the page getting reloaded..
because your code will located in server which secure enough. so its not possible to edit from client side tool like Developer console
But if you can prevent user to get into Developer tools .
user following ctrl+shift+i or F12 or Right Click->inspect Element way to get into it.
you can still disable those prevent user to enter into Dev tools.
for more info how to disable dev tools

Django: How to make an API call just before browser tab close?

I am using Django v1.10 for an application where in need to send an API call just before browser close through crude javascript (don't want to use any library for sake) preferably. I've read about window.unload and window.onbeforeunload. The first one didn't seem to work at all. The second can work but it also gets executed when there is reload or redirection to another page (it works as it should but that is what I don't want). I've tried using SESSION_EXPIRE_AT_BROWSER_CLOSE of Django which works only when a user has totally exit out of the browser (no browser process running). I've also seen answers on the web where people have suggested to open another window/tab of the browser through JS as the tab closes.
So in precise words, I want to make an API call just before browser tab close (not in any other situation).
Please help!

Firefox/Chromium plugin to catch all AJAX requests?

My situation is as follows: I have some Javascript code that I did not write myself, but I that I would like to get acquainted with (actually, I want to debug it). In particular, I am interested in what AJAX requests this code makes, and when.
This Javascript code I'm looking at is quite complex and lengthy and chaotic. So basically, just reading the source code or grepping the source code for this or that function call is not a good option. What I would like is some Firefox or Chromium plugin (whichever works) that does the following:
While loading the page and executing the Javascript, I would like it to catch any AJAX request that is made and tell me about it (most importantly, what URL is being called, though knowing what POST parameters etc. are travelling along that request would be useful as well). It would be awesome if it actually stopped before each execution of an AJAX request, told me about it, and asked me if it should proceed. But I would also be happy even if it did nothing else but simply print each URL that the Javascript sends an AJAX request to into a console or something.
Any suggestions?
You can do this in Chrome without needing any plugins, or in Firefox with the Firebug plugin:
side-note: when I say "XHR" I mean "XML / HTTP requests", which is what ajax requests fall under.
In Chrome
Just open your Dev Tools (F12), and go to the Network tab (second tab in Chrome 32). From the moment you open the tab on, all requests are logged there. Click the third icon at the top of the Network tab (says "filter" when hovering over it) and then select the "XHR" filter, which will limit it to just XHR.
You can also right click in your Console tab and select the "Log XMLHttpRequests" option, which will then log all XHR in your console too.
In Firefox
Open your Firebug, and open your Net tab (second last tab), and click "Enable" in it (default is disabled). From the moment you enable the tab on, all requests are logged there. At the top bar within that tab, you can click the button that says "XHR" to limit it to XHR only.
You will also by default see all XHR in your console in Firebug.

how to disable javascript in chrome by code

we kown that chrome provide us the method to disable js in web developer Panel.
but i want to disable js from chrome extension by the interface if chrome provide
if chrome dont allow developer do this ,
if i can get the list of the element banned loading when set disabled in panel.
thank you
If you're trying to stop a particular script from loading (is that right?), consider using Chrome's webRequest API to stop it from even being loaded in the first place. The API reference contains an example of how to cancel a request. (Note that the first example is for demonstration purposes; the second example is more efficient if you know the URL in advance.)

Categories