Jump to content

ajax uncaught exception: send(null)


zamandil

Recommended Posts

hii

i am trying to get response from domain https://www.dex-intl.com/data_access_layer/search_box_dal.php through ajax call, but getting following exception

 

uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://localhost/projects/mtdb/Ajaxcall.php :: loadajex :: line 39" data: no]

 

/////my code is

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Testing Ajex</title>

<script type="text/javascript">

function getHTTPObject()

{

var xhr = false;

if (window.XMLHttpRequest)

{

xhr = new XMLHttpRequest();

}

else if (window.ActiveXObject) {

try

{

xhr = new ActiveXObject("Msxml2.XMLHTTP");

}

catch(e)

{

try

{

xhr = new ActiveXObject("Microsoft.XMLHTTP");

}

catch(e)

{

xhr = false;

}

}

}

return xhr;

}

var request;

 

function loadajex(){  

    var request = getHTTPObject();

    request.open("GET",'https://www.dex-intl.com/data_access_layer/search_box_dal.php?msgno=333333',false);

request.send(null);

    if(request.status==200){

        alert(request.responseText);

  }

}

</script>

</head>

 

<body>

<div>Call to <a href="" onclick="loadajex()">Dex-intel.com</a></div>

<div id="response"></div>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/198104-ajax-uncaught-exception-sendnull/
Share on other sites

It looks like your problem is a result from trying to access information from another domain than the one where your script resides. Explained here:

 

XMLHttpRequest can only access content from the originating server. If your application lives at http://ajax.shop/admin, then your XMLHttpRequest objects can happily read http://ajax.shop/admin/products.html  and http://ajax.shop/products/contents.html, might be able to read http://books.ajax.shop/contents.html (there's not much documentation on subdomain access, making this a portability concern at best), and definitely won't have access to http://google.com.

 

If you want to do this you will need a php proxy script on your server that fetches data from the other domain. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.