PDA

View Full Version : form.load option's url must be .php file?



syczx
2 Nov 2010, 8:49 PM
form's load method,option's url test code:

This is load success:


form.getForm().load({
url:'data.php?xx='+new (http://www.sencha.com/forum/'data.php?xx='+new) Date(),
waitMsg:'wait please...',


data.php:


<?php
echo '{"success":true,"data":{"user":"admin","password":"pretty","checkcode":"123456"}}';
?>


This is load failure:


form.getForm().load({
url:'data.js' (http://www.sencha.com/forum/'data.js'),
waitMsg:'wait please...',


data.js:


{"success":true,"data":{"user":"admin","password":"pretty","checkcode":"123456"}}


Why is this?

Condor
3 Nov 2010, 12:35 AM
Are you trying to load data.js from the local filesystem? That's not supported - you need to host your app on a HTTP server.

ps. In your PHP you should also set the Content-type to application/json.

syczx
3 Nov 2010, 12:49 AM
My test is running on my HTTP server : http://www.mm2bb.net/test/t2/

Which php file is loaded is success,but data.js failure.

Why is this?

Animal
3 Nov 2010, 1:08 AM
You'll have to debug.

Condor
3 Nov 2010, 1:10 AM
Have a look at the Firebug Net tab. Does the data.js file get returned correctly?

syczx
3 Nov 2010, 1:12 AM
OK,I'll debug at once.

syczx
3 Nov 2010, 1:26 AM
The problem was finded!
Because use 'POST' to access in load default,but data.js cann't access in 'POST'.
Add method:'get' in options,The problem was resolved.

Thanks for everyone!