With the XMLHttpRequest(); you have now you try to get the file from
the local disk which is not possible since there is no webserver
involved when doing so (meaning that the PHP does not get executed).
You have to use a fullhost instead eg. req.open("GET", "http://
yoursite.com/autocomplete.php?value=testValue", true);
This does mean you have to run the file on a webserver.For more info: http://code.google.com/chrome/extensions/xhr.html On Jan 20, 9:36 pm, nathan <[email protected]> wrote: > I am trying to write a simple chrome extension that receives input > from the user via an input text box. It sends that input to a php > page that will generate some results and then display the results > right below the input box. > > I'm using XMLHttpRequest to run the PHP page but the response that I > am getting back is empty (according to the console). If I alert the > responseText then it will show the raw php code. This works perfectly > if I just load the popup.html in chrome but does not work if I load it > in the extension or if I load it using chrome-extension://<id>/ > popup.html. > > This php request is not cross-origin. The php page is in the exact > same folder as the popup.html. > > Here is my request code: > var req; > function goGet(){ > req = new XMLHttpRequest(); > req.open("GET", "autocomplete.php?value=testValue", true); > req.onload = handleResponse; > req.setRequestHeader('Content-Type', 'application/x-www-form- > urlencoded'); > req.send(null); > > } > > function handleResponse() { > var doc = req.responseText; > alert(doc); //Returns the raw PHP code > var content = document.getElementById('content'); > content.innerHTML = doc; > > } > > Thanks for any help.
-- You received this message because you are subscribed to the Google Groups "Chromium-extensions" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en.
