download progress with jsonp via ajax - ajax

In an internet very many example how extend $.ajax for get download (or upload) progress.
This example work perfect with plain-text, xml, json, but not work with jsonp. There are no reaction from event-listeners. I wrote this example on pure javascript, but no result. I know about script-append-to-DOM-way. Using this method can not get progress.
How i can get download progress with jsonp and via XMLHttpRequest?

I know about script-append-to-DOM-way.
JSONP is the script-append-to-DOM-way. There are no "progress" events on script tags AFAIK.

Related

Getting the JSON file when triggering AJAX

I'm writing a crawler to get the content from a website which uses AJAX.
There is a "show more" button at the bottom of the page, and my origin approach is to use Selenium.PhantomJS to pretend a web browser but it works in some website and some don't.
I'm wondering if there is some way i can directly get the underly JSON file of the AJAX action. Please give me some details, thanks.
By the way, I'm using Python.
I understand this is less of a python than a scraping problem in general (and I understand you meant "scraping" instead of "crawling" as a scraper reads/parses/processes one page whereas a crawler processes multiple pages and they're relation to each other).
You can get the JSON file immediately given you know it's URL. If you don't (for example because the URL changes from time to time), you might need to search through javascript files on the page manually to find out how the URL is generated.
Once you know the JSON file's URL, it's quite simple. As you already seem to know how to get the HTML of the "main" page, you can use your existing code to get the JSON file.
I'm not familiar with PhantomJS, but I reckon it's easier to get the JSON file immediately instead of simulating an AJAX request (if that's even possible with Phantom).

In Rails how do I use ajax? where do I put my Ajax code?

How do I get data from the database, without refreshing the page?
I dont even know where to start...
In Rails you will need to implement a page that pulls data from the DB and shows the data in whatever format you prefer, plaintext/json/xml. There's no asynchronous stuff in this part.
Ajax will be happening in frontend, the javascript part, that asynchronous connects to the webpage that you made above. jQuery's $.ajax will save you a lot of time.
You'll need to make your AJAX call from either an onload.js or a page specific js file (example.js). You'll then need to run a $.get or $.post call to the URL of the data.
Here is a pretty detailed tutorial: http://www.tutorialspoint.com/ruby-on-rails/rails-and-ajax.htm

How to use ajax post on webmatrix webimage helper especially in webimage.getImagerequest()

I've been trying to use the webimage helper in webmatrix to upload an image using ajax but its not clear to me how i can pass data to the webimage.getImageRequest("Image") method from the ajax post.This helper seems to retrieve its file upload data from the browser when the page form is posted.For me, i dont want to refresh the form...I just want ajax to handle process
The issue here isn't the WebHelper - uploaded files are not posted with ajax requests:
How can I upload files asynchronously?
So you're probably getting a file name, but no content. That thread above shows a few work arounds that should work fine with the WebHelper. I've also had pretty good luck with uploadify:
http://www.uploadify.com/
Happy Coding!

Is there a way to find the id of an ajax xmlhttprequest?

One of my pages has about 5 jQuery AJAX calls that fire off as soon as the page loads. I want to track each AJAX call individually and get it an id. How do I do this?
Download the Firefox browser and install the Firebug extension. That will let you track all the XMLHTTP request information for each request (as well as help you with plenty of other debugging issues).
Here's a basic overview: http://getfirebug.com/network

Browser extension for AJAX calls

I'm looking for browser extension (for Firefox or Google Chrome) that allow me to make AJAX calls. I'd like to specify:
Method (POST/PUT/GET/DELETE)
URL
Data to send (JSON/XML)
I know that I can make AJAX call from console, but it's nice to have dedicated tab for that.
I've found 2 nice extensions:
cREST Client - https://chrome.google.com/webstore/detail/baedhhmoaooldchehjhlpppaieoglhml
XHR POSTER - https://chrome.google.com/webstore/detail/akdbimilobjkfhgamdhneckaifceicen

Resources