jQuery自定义Ajax构建

I'm trying to strip everything except for ajax functionality from jQuery. Sorry for the silly question, but hear me out:

  • I'm using web workers to make the ajax call so I can't have the core.js stuff in there.
  • Another library I'm using calls jQuery and I haven't been able to get it to work with the jQuery.Hive.Pollen library. After many hours of troubleshooting it seems like this ChemDoodle Web Components library only works with jQuery and I'm not experienced enough to know why.
  • Seems like a pretty easy thing to do to use the makefile to build jQuery, but I'm not sure what to include. In the makefile, I took out everything except the ajax-related stuff:

.

BASE_FILES = ${SRC_DIR}/ajax.js\
    ${SRC_DIR}/ajax/jsonp.js\
    ${SRC_DIR}/ajax/script.js\
    ${SRC_DIR}/ajax/xhr.js\

However, further inspection of the /ajax source files shows methods that call 'document'. So that means that this won't work at all no matter how many modules I strip right?

Update: Bug issue #9889 on jQuery seems to indicate that core will never provide an ajax function usable by web workers, at least not anytime soon.

A bit of a description of what I am trying to do and why I need to use web workers, for anybody interested. I'm putting a distributed computing application that does some molecular simulation/screening from a database of compounds. Normal javascript won't work because it will slow down the page and I want the application to continuously run in the browser, computing one molecule after another. Here's a pseudocode outline of my desired web worker

while (true){main();}

main(){
 get job from server via ajax
 process data//must use web worker
send results to server via ajax
}

Yes, I could implement my program to unserialize a data string passed from the main page and get the page to fetch the ajax data, like so

//page-side javascript
var slave = new Worker()
slave.onMessage(event){
if status = "ready" {
check if data is available- if so, send it to server via ajax
fetch job data from server via ajax
slave.postMessage(job data)
}
}

//worker (slave)
self.onmessage(data) {
//process results
//send back to page
}

I guess this could work but it's a little tacky and probably is slower than just having the worker do everything. According to Rick Waldron, "if you had a system that was polling eg. open a worker, make xhr requests in a loop forever, on each response, postMessage() the results back to the client, then you can benefit"

I guess I am making xhr requests in a loop forever so this application would be beneficial.

I did find jQuery.Hive.pollen.js, but it is not working with my other library that makes the ajax call I need. It's a separate question though (actually my main question), so if anybody is interested here is a link to that post:

Ah, I haven't figured the jQuery issue out but I know now how to make pollen.js more like jQuery.

Delete (or comment out) the two request headers in pollen:

_xhr.setRequestHeader("X-Requested-With", "Worker-XMLHttpRequest");
_xhr.setRequestHeader("X-Worker-Hive", "Pollen-JS" );

and unlike jQuery, pollen.js's ajax function returns a JSON object containing the JSON data returned by the server as well as a stringified form.

data = {"json":{jsonobjecthere},"text":"stringifiedversionofthedata"}

If those two modifications are made, then I believe pollen is nearly the same as jQuery's ajax