500 (Internal Server Error) when using ajax in Joomla? - joomla2.5

I wanna using Ajax at front-end joomla site
I have found and tried some code about call ajax in Joomla! but unfortunately It don't run.
Here is my code:
File : components/com_headattack/views/headattackinfo/tmpl/default.php
$("#select-filter1").selectbox({
onChange: function (val, inst) {
$('#select-filter2').remove();
$.post("index.php?option=com_headattack&task=filter1_click&format=raw",
{
elementId : "select-filter1",
selectedValue : val
},
function(data,status){
$('#select_filter_div2').html(data);
}
);
}
});
File : components/com_headattack/controllers/headattackinfo.php
public function filter1_click(){
return "test";
}
When I run my site and click select-filter1(combobox) so javascript throw a message : 500 (Internal Server Error)
Please help me to solve my problem :(

Your task currently maps to the main controller in the component: components/com_headattack/controller.php
To have the task run in that controller, you should call task=headattackinfo.filter1_click (the controller, a period, then the function name).
The full url would look like this:
index.php?option=com_headattack&task=headattackinfo.filter1_click&format=raw

Related

Lucee ColdFusion.Ajax.submitForm

I'm converting a site from ColdFusion to Lucee (for the first time). In ColdFusion, after using the cfajaximport tag, I can run JS code similar to this:
ColdFusion.Ajax.submitForm('runMe', 'runCode.cfm', callback_testMe, errorHandler_testMe);
I seem to be unable to run this in Lucee. I'm looking for some kind of Lucee alternative, but can't seem to find anything.
Basically, I'm wanting to submit form data, run some server side stuff, then return the results without refreshing the page.
Any help would be greatly appreciated.
Lucee does not have CF UI tags, you're going to have to do this with jQuery AJAX or similar.
var formID = "runMe"; // formId Param
$("#"+formID).on("submit", function (e) {
e.preventDefault(); // Prevent page load
$.ajax({
type: "POST", // httpMethod Param
url: "runCode.cfm", // URL Param
data: $(this).serialize(),
success: function (data) {
console.log(data); // callbackhandler
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(thrownError); // errorHandler
}
});
})
This should do exactly the same thing and I even pointed out the similar params from ColdFusion.Ajax.submitForm

Ionic 2: Loading screen does not get dismissed

I have an application made with Ionic 2, The work flow is like this
Case A . When user is using app for the first time
User Logs in (loading is shown)
When successfully logged in loading window is hidden and user is forwarded to Dashboard page.
In dashboard page items are loaded via ajax request.
Case B. When user is already logged in before
The first screen is Dashboard and items are loaded via ajax request.
Problem
In case A, when user logs in and forwarded to DashboardPage, the loading screen doesn't gets dismissed. Sometimes it gets dismissed but most of the time it doesnot? Is this an ionic bug or am I doing something wrong??
Here is my DashboardPage
//imports here
export class DashboardPage {
public loadingmsg: any;
public ajaxRequest: any;
constructor(
public navCtrl: NavController,
public navParams: NavParams,
private webservice: WebService,
private loadingCtrl: LoadingController
)
{
this.loadDashboardContents();
}
loadDashboardContents(){
//other codes
this.loadingmsg = this.loadingCtrl.create({
content:"Loading contents, please wait..."
});
this.loadingmsg.present();
this.ajaxRequest = this.webservice.getDashboardContents(params).subscribe(data => {
this.loadingmsg.dismiss().then(()=>{
//other codes to save retrieved data to localstorage.
});
});
}
}
UPDATE
The login method from login page
loginUser(){
this.loading=this.loadingctrl.create({
content:"Logging in, please wait..."
});
this.loading.present();
this.ajaxRequest = this.webservice.loginUser(params).subscribe(data => {
this.loading.dismiss();
if(data.status =="ok"){
this.navctrl.push(DashboardPage).then(()=>{
const index = this.viewCtrl.index;
this.navctrl.remove(index);
});
}else{
//show error alert
}
}, err =>{
this.loading.dismiss();
});
}
My Ionic and cordova version information
Ionic Framework: 3.5.0
Ionic App Scripts: 1.3.9
Angular Core: 4.1.3
Angular Compiler CLI: 4.1.3
Node: 6.10.3
OS Platform: Windows 10
Cordova Version: 6.5.0
I am currently using loading in my project and it works well in all case. To ensure loading will always dismiss you need to add some code:
1. duration, dismissOnPageChange
let loading = this.loadingCtrl.create({
content: "",
duration: 5000, //ms
dismissOnPageChange: true
})
2. dissmis when ajax call success or error:
.subscribe(success=>{
//some code
loading.dismiss();
},error=>{
//some code
loading.dismiss();
})
It may be due to the this reference inside your subscribe method. I would try declaring loadingmsg locally and removing this.
loadDashboardContents(){
//other codes
let loadingmsg = this.loadingCtrl.create({
content:"Loading contents, please wait..."
});
loadingmsg.present();
this.ajaxRequest = this.webservice.getDashboardContents(params).subscribe(data => {
loadingmsg.dismiss().then(()=>{
//other codes to save retrieved data to localstorage.
});
});
}

Pretender intercepted GET ... but no handler was defined for this type of request for an external request

I use Stripe in an Ember app. Stripe makes request to this address : https://checkout.stripe.com/api/outer/manhattan?key=... In my acceptance test, I have this message : Pretender intercepted GET https://checkout.stripe.com/api/outer/manhattan?key=... but no handler was defined for this type of request.
I tried to stub this request like this :
var server = new Pretender(function() {
this.get("/api/outer/manhattan", function() {
return [200, {}, this.passthrough];
});
});
But it does not work. I also tried with the full url or with a wildcard without success.
Is there a solution ?

soap based web service in BB 10

I am just started development in BB10 .I need to call soap based web service from URL .I google it and found one weather example .But it not help me.Actually I want to to call a method Example like
getVersionReturn .
from url so that my concept clear .Then I will call my other methods
here is my url.
http://railapps.firstgroup.com/FirstGroupRailApps/services/RailAppsCAWS?wsdl
The return value is response like :1.3 .
can you help me to call one method on button click ?
Ok this isn't full solution, but it will show you the important part (this is cascades solution)
Button {
text: "click"
onClicked: {
dataSource.load();
}
}
and
attachedObjects: [
DataSource {
id: dataSource
source: "http://railapps.firstgroup.com/FirstGroupRailApps/services/RailAppsCAWS?wsdl"
type: DataSourceType.Xml
remote: true
onDataLoaded: {
console.log(JSON.stringify(data))
}
onError: {
console.log(errorMessage)
}
}
]
so all you need to do is to search through that data.

Getting callback is undefined error in firebug console while creating a datasource using kendo ui

My webservice generates jsonp response same as http://demos.kendoui.com/service/products.
When i try to create datasource for my webservice i am getting callback is not defined error in firebug console.
Webservice response.
callback([{"category":null,"productName":"Puma","productId":1,"quantity":0,"price":3000.0,"categoryId":1,"description":"ok"}])
But when i use kendo ui webservice (http://demos.kendoui.com/service/Products) i am getting a valid datasource.
Code :
$(document).ready(function() {
var dataSource = new kendo.data.DataSource({
transport: {
read: {
//url: "http://demos.kendoui.com/service/products",
url: "http://localhost:8080/mobile-services/rest/categories/1/products.json",
dataType: "jsonp"
}
},
pageSize: 12
});
$("#pager").kendoPager({
dataSource: dataSource
});
$("#listView").kendoListView({
dataSource: dataSource,
template: kendo.template($("#template").html())
});
});
please suggest.
I guess the function name is not callback callback is just the key and the function itself maybe called sth like jQuery17101014779508113 Can you look at what your datasource is sending to the server during the read operation? (Chrome / Firebug Network Tab) I'm taking the $_REQUEST['callback'] variable (with a PHP-Script) and just returning it as the padding. Since you're just using a static .json file and the callback function name will be changed on each request (to prevent caching), you won't ever have the correct function name.
So: I suggest you use JSON instead of P or you dynamically return the same callback you're receiving.
Cheers....
You have specified JSONP as dataType and you are requesting a JSON file. JSONP and JSON are not the same. Try using dataType: "json".