Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
Posts: 13
Registered: ‎09-25-2011
My Device: Blackberry 9000
My Carrier: Digicel

Jquery, PHP in webworks application

[ Edited ]

I compiled a webworks application and in the zip file there is a php file. Could it be possible to use JQuery and load the php file (using jquery's .load("file.php") ) in a div on the src index.html page?

 

I tried it and it didnt work.

 

I have something like this on the infex.html page.

 

 

function onError(msg)
{
	$("#thediv").load("error.php");
}

 

not sure what is the problem

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Jquery, PHP in webworks application

You are not able to load PHP, ASP, JSP, or other server executable code into a WebWorks application and run them locally on the device.

 

These are all server side based technologies that require a certain runtime to execute their contents.  You would have to place your PHP file on the server and run it from there.

 

You can load any local content that the browser will support such as HTML, CSS, JavaScript.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Contributor
Posts: 13
Registered: ‎09-25-2011
My Device: Blackberry 9000
My Carrier: Digicel

Re: Jquery, PHP in webworks application

[ Edited ]

Thanx, but using the example above, how would i call it from the Webworks application?

Developer
Posts: 817
Registered: ‎11-19-2009
My Device: Z10, Q10, 9900, 9790, PlayBook,
My Carrier: T-Mobile UK, Three, O2, Orange, Sunrise, Swisscom

Re: Jquery, PHP in webworks application

You should make an AJAX call to that PHP page and render the content in your div
--
Olivier - interfaSys ltd
Developing for BlackBerry 10 devices using the Sencha Touch framework.
Contributor
Posts: 13
Registered: ‎09-25-2011
My Device: Blackberry 9000
My Carrier: Digicel

Re: Jquery, PHP in webworks application

Thanks, but can i make an AJAX call from the bb application to a php page on a server? wouldnt that be a cross domain ajax call?

Developer
Posts: 817
Registered: ‎11-19-2009
My Device: Z10, Q10, 9900, 9790, PlayBook,
My Carrier: T-Mobile UK, Three, O2, Orange, Sunrise, Swisscom

Re: Jquery, PHP in webworks application

It would, but because you package your app as a WebWorks app, you can tell it to bypass that restriction by using config.xml

http://docs.blackberry.com/en/developers/deliverables/30182/Widget_element_834671_11.jsp#Access_elem...

--
Olivier - interfaSys ltd
Developing for BlackBerry 10 devices using the Sencha Touch framework.
Contributor
Posts: 13
Registered: ‎09-25-2011
My Device: Blackberry 9000
My Carrier: Digicel

Re: Jquery, PHP in webworks application

K, thanx. After adding that attribute to the config.xml file could i then write something like this?

 

function onError(msg)
{
	$("#thediv").load("www.mydomaininconfigfile.com/error.php");
}

 

Contributor
Posts: 13
Registered: ‎09-25-2011
My Device: Blackberry 9000
My Carrier: Digicel

Re: Jquery, PHP in webworks application

Ok, i got the app to get a request using a JSON call.

 

$.getJSON('http://www.domain.com/file.php?myjsonfile=2&jsoncallback=?',function(data){

$.each(data.thearray, function() {

alert(data.theelement);

});

});

 On the browser this works and alerts the json information, however when i compile the file and deploy it on a blackberry the app makes the call to the php file, however it doesnt return and alert the json file information. Anybody knows wat i could be doing incorrectly? thanx