here is my code of the index page index.htm :
<!DOCTYPE html>
<html>
<body>
<form>
write ur text here: <input type="text" name="UrText" />
</form>
<button onclick="startWorker()">Start Worker</button>
<button onclick="stopWorker()">Stop Worker</button>
<br /><br />
<script>
var w;
function startWorker()
{
if(typeof(Worker)!=="undefined")
{
if(typeof(w)=="undefined")
{
w=new Worker("worker.js");
}
w.postMessage = function(event){
document.getElementById('UrText').value;
//here i send the text from the text field to the worker
};
};
}
}
function stopWorker()
{
w.terminate();
}
</script>
</body>
</html>
and that is the code for my worker file worker.js:
function UploadText()
{ var SentData;
onmessage = function ({
/*here is supposed to get the message but its giving me an error undefined UrText, im pretty sure its totally wrong i wanna knw how to do it*/
document.getElementById('UrText').value;
})
//this is the ajax code part to send the text to the php file
var ajax = new XMLHttpRequest(),
params = "SentData=" + escape('UrText');
ajax.open("POST", "fileupload.php", true);
ajax.send(params);
}
also i need to know if im doing it right sending it to the php file that way?..and if im wrong n im pretty sure im wrong how can i do it? thank you. =)
sorry for the shallow question, my question is how can i pass the text from the javascript to the worker? its not working with me this way, also how to pass it from the worker to the php file as well after the worker recieving it? thank you

New Topic/Question
Reply


MultiQuote




|