Note that there are some explanatory texts on larger screens.

plurals
  1. POxmlHTTPrequest won't open ("GET" , url, true); I'm miffed! PHP
    primarykey
    data
    text
    <p>I've been trying to get a url to open but I'm miffed as to why this hasn't worked. The code is listed and explained below. Any help will be deeply appreciated.</p> <p>The object:</p> <pre><code>function getXMLHTTPRequest() { var req = false; try { /* for Firefox */ req = new XMLHttpRequest(); } catch (err) { try { /* for some versions of IE */ req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (err) { try { /* for some other versions of IE */ req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (err) { req = false; } } } return req; } </code></pre> <p>The object is called like this:</p> <pre><code>&lt;script type="text/javascript"&gt; var myDelete = new getXMLHTTPRequest(); &lt;/script&gt; </code></pre> <p>Now here's what I want to do:</p> <pre><code>function removeArticle(id) { if (myDelete) { try { var deletUrl = "delete.php"; var query = deletUrl + "?theid=" + id; myDelete.open("GET", query, true); myDelete.onreadystatechange = removeArticleResponse; myDelete.send(null); } catch (e) { alert ("Unable to connect to the server:\n" + e.toString()); } } else { alert ("Bad! Very BAD!"); } } </code></pre> <p>When I do this:</p> <pre><code> if (myDelete.open("GET", query, true)) { myDelete.onreadystatechange = removeArticleResponse; myDelete.send(null); } else { alert ("No road!"); } </code></pre> <p>The alert("No road!"); shows me that the code doesn't execute passed this point: </p> <pre><code>if (myDelete.open("GET", query, true)) { </code></pre> <p>This means that the if (myDelete) { works. The code passes this stage and for some reason stops here: myDelete.open("GET", query, true); It won't open the url. I'm not sure what the problem is. </p> <p><strong>Edit:</strong> Here's the function used to access the server response:</p> <pre><code>function removeArticleResponse () { if (myDelete.status == 4) { if (myDelete.status == 200) { try { response = myDelete.responseText; document.getElementById('displaynewsletterarticleresult').innerHTML = response; } catch(e) { alert("An error occured while reading the response:" + e.toString()); } } else { alert ("An error occured when attempting to retrieve the data:\n" + myDelete.statusText); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload