JQuery $.post not working on some PCs - javascript

I have a very strange problem with JQuery $.post()
I have implemented it in my new web application and get messed response from QA after testing, some say it is working perfectly and some say it is not working;
It generate no error and no warning,,, but i am very upset i have almost compeleted the application and it is impossible to use some alternative,,, please if some one has any idea then please help me.
Regards

I suggest you to write a simple test page that makes only a $.post call and print a result (like 'test passed'). This way you can be sure that there is no other problem in your application causing the error. Afterwards you can send this link to the QA and see if the XHR requests are really working (or not).

Maybe the specify computer setting, such as different browsers or browser security configuration or others, check then step by step. You should may the error logs more detail. otherwise you can use HTTP sniffer tools such as firebug, ieinspectoer..

Related

Request Blocking Using Javascript?

How to block requests from a certain URL using JavaScript? For example, the manual way to do so on chrome will be to open the inspect page, go to network and block from there. But I need to block requests from certain URLs for an automated test that i am writing in JavaScript (using testcafe, if that offers any help).
Here are screenshots of manually blocking a request from chrome, I want to do the same thing automatically in my test/JavaScript:
ScreenShot1
Screenshot2
Thank you.
Edit:
I tired following this post: Blocking request in Chrome
but for some reason i always keep getting an error stating that chrome is undefined when I use chrome.webRequest
You can use the nock library, which allows you to intercept requests and process them as you wish.

Running Browser as terminal process

I am trying to do some high scale testing with my nodejs server so I want to find out how its possible to run the chrome browser on the terminal, similar to how nodejs runs the server.
I want to have a few hundred on a single machine which is why I want to avoid running the actually browser tab instances. It also needs to specifically be google chrome.
Right now Im trying to figure out how this is possible, even if it's just somehow running the messaging javascript from the terminal.
Can someone please point me to the right direction :]
Have you looked into Request, CasperJS, or PhantomJS? I think they may be just what you're looking for. Phantom is a headless browser that can browse webpages for you (useful for testing, taking screenshots, and taking actions on pages for you). CasperJS can help you out with that, as well, and Request allows you to make http requests from your server, rather than client. If you need to search/ traverse the page your server gets back, you can also use Cheerio, which is pretty much jQuery for your server.
Hope that helps!

Change web page content in real time without ajax

I realized at a moment with the help of firebug in stackoverflow.com, when someone accepted your answer, suddenly your points got increased without any Ajax hit received to any method. Amazing, How is it possible?
Please advice so that i can try to implement this technique into my upcoming projects. Thanks in advance.
Make sure you have looked into the net option. There are two ways I can tell.
Web Sockets
iFrame
Please have a look at http://www.html5rocks.com/en/features/connectivity & http://html5demos.com/web-socket
But will work on limited browsers
Using iFrame with simple get request no ajax call will made but you will be able to see it firebug net. This is what Facebook uses and all browser compatible.
It's using WebSockets instead of AJAX XMLHttpRequest in modern browsers. You can find more details about Stack Overflow's implementation on meta.stackoverflow.com.
The main advantage of WebSockets is the server can send an update to the browser the moment you receive an upvote. Other methods, such as XHR and hidden iframes, require the browser to poll the server at regular intervals to get an updated vote count.
you could use an image submit button and submit to an small iframe that displays the number.
otherwise you'd still be messing around with an hidden iframe and submits or gets posts in a hidden iframe.
If you really want a javascript less solution the form submits hidden/small iframe are the way to go.

In Firefox how to find out the code line that makes a request?

Is there an extension or Firebug feature that will tells me the exact line and file from which a HTTP request is made?
In Firebug, the Net tab shows the HTTP headers but not the line that triggered the request. The Console tab will report request with error codes and their expected URL but again without the line where the request is made from the CSS, JavaScript or HTML file.
Thanks in advance.
EDIT: A possible use case is to be able to quickly see in the browser image requests that return 404 - in which file (there might be several CSS files) the request was initiated and the line.
No Firebug feature (most likely no extension either)
Firebug doesn't display that and what's even more is that most production-level web applications use minified scripts so this info wouldn't be valuable anyway...
If you're developing an app, you don't use minified scripts but then you know which call initiated a request. But if you're looking at other running apps than minification will make it impossible to determine calling code.
Search in files
Many text editors nowadays support search/find in files feature which makes it possible to search several files at once so you don't have to do it manually yourself. Simple editors like Notepad++ support this as well as several IDEs (like Visual Studio). This makes it simple for you to find culprits that requested those missing files1.
1: But I agree... Such feature would be great if supported directly in Firebug.

What's an easy way to see what AJAX calls are being made?

I'm looking for something (preferably a Firefox extension) which will allow me to see all AJAX subrequests. Basically, anytime an XMLHTTPRequest() is made, I want to know what URL was being requested and what (if any) GET and POST vars were passed along with it.
Unless I'm missing it, I don't see anything quite like this in Firebug or Web Developer Toolbar.
(In case you're curious, the main reason for wanting this is that I want to scrape a local copy of a site that is using JS to load all its contents, and I don't want to spend hours digging through their JS code when I could just see the subrequests being made.)
Firebug should show it in the Net panel.
EDIT: Also, if Firebug slows down your Firefox in a way that makes it unusable, like it does for me sometimes, WireShark (formerly Ethereal) will analyze all network traffic on your system, including HTTP and AJAX requests.
Fiddler 2 is a great tool for watching HTTP traffic.
* 2014 Update *
Since my original post, both Internet Explorer and Chrome have added built-in developer tools that are quite useful. While I still support and use Fiddler for non-web related http monitoring or when I need to really dig in deep and modify requests in transit, these days I find myself pretty much using IE or Chrome's built in tools as they are sufficient for 99% of my needs. They both have a networking tab, where you can monitor http requests, plus other nifty features for debugging webpages.
Internet Explorer F12 Tools Introduction
Documentation for Chrome's F12 Tools
FireBug, which is mentioned above is also a good tool if you're using FireFox.
I have used nearly all the big tools out there (fiddler, firebug, httpfox, live http headers). The best one in my opinion is HTTPFox if you are using Firefox because it has easy filtering capabilities, allows you to view your JSON the request/response as raw or formatted and the over all interface is very clean.
Also, I can't do without WFetch for testing web services and AJAX stuff. Usually I'll take the request from HTTPFox and paste it into WFetch. This way I don't have to go through the browser each time. I just hit F5 in WFetch to replay the request and I directly modify the request.
Side note: In WFetch, be careful about content-length if you have a POST payload. If you modify the payload the content-length needs to be changed as appropriate. For this reason I save my requests in a file and point WFetch to the file. In the file itself it is easy to know the length of the line and change content-length to that.
(source: koreus.com)
alt text http://www.port80software.com/assets/images/ld_wfetch3.gif
Firebug shows them in both the Net panel, and the Console view. You need to turn on "Show XMLHttpRequests" though.
Have a look at Tamper Data as well. It's a Firefox add-on that lets you have a look at each individual HTTP request (including any post data) and response, and the headers of both. I've found it very useful for debugging AJAX problems...although Firebug works just fine.

Categories

Resources