Yeah, I don’t know much about JavaScript (as you might tell )
I put it where you said and I still get the same error: Uncaught TypeError: Cannot read property ‘html’ of null
function getnp(){
var order_id = document.getElementById("order_id").value;
$("div#jfjfjf").html('<br><br><br><div style="background: url(<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif', array('_secure'=>true)) ?>);width:16px;height:16px;text-align:center;margin-left:270px;">');
$.ajax({
type: "GET",
// url: '<?php echo Mage::getUrl('rma/index/order') ?>',
// url: '<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);; ?>/oproducts.php',
url: '<?php echo Mage::getUrl('rma/index/order',array('_secure'=>true)) ?>',
data: "oid="+ order_id , // appears as $_GET['id'] @ ur backend side
success: function(data) {
// data is ur summary
alert(data);
$('#jfjfjf').html(data);
},
error: function(jqXHR, textStatus, errorThrown) {
alert(textStatus);
alert(errorThrown);
alert(jqXHR);
}
});
return true;
}
I’ve added a error possibility for see error (if there is any error).
The error is probably in your php script (indicated in url), and this url return nothing. You can try to see this by accessing at this url. For example if your url is http://mywebsite.com/mypage.php, so you should enter that in your browser and see result http://mywebsite.com/mypage.php?oid=123.
Yeah, but what is displayed to screen ? In all case there is a message at your screen.
Please try to understand, we try to understand where is the error and not try to fix for the moment. When we have found where is the error then we’re going to try to fix them.
You use the url where you have the code. Your ajax doesn’t try to fetching from this url.
You show your javascript code with php, but not the javascript code generated, so I can’t see what your php function return.
you call a ajax function that try to get some content at /rma/index/order?oid=37024
you try to add the content of the ajax request into a html node. (#jfjfjf).
BUT ! you just said:
So, that mean, you try to add to content of the node: null. Here is the error. Javascript don’t like null value.
You must understand the problem is your php page. (/rma/index/order?oid=37024) This page must return a content, but instead of a content, it’s return nothing. (null)
“data” undefined sounds like there is a problem with data not being returned.
But I’m wondering it it’s really the “html” that is the problem. i.e. what’s being returned is not HTML (a JSON object?)