Reputation: 1805
I am working on creating a widget. My jquery function is:
function init_widget(params){
var protocol=window.location.protocol;
var host=window.location.host;
$("#wd_id").load(protocol+"//"+host+"/testfolder/index.php");
}
As in above code, I am loading 'index.php' using jquery. I also want to pass the value in param variable to index.php
. I have tried it using ajax, by doing something like
function init_widget(params){
var protocol=window.location.protocol;
var host=window.location.host;
$("#wd_id").load(protocol+"//"+host+"/cropimages/index.php");
$.ajax({
type: 'POST',
url:index.php,
data: param,
success: function() {
alert('asdf');
},
error: function(){
alert('failure');
}
});
}
But, it is showing error as Uncaught ReferenceError: param is not defined
. Does anyone have any clue why this is happening. Any kind of positive suggestions are appreciated.
Thanks in advance....
Upvotes: 0
Views: 243
Reputation: 2843
You use params
(with -s suffix) as the argument name, but try to reference it as param
(without -s suffix) in the function bodies. You should change the argument name to param
as well.
Upvotes: 1