Hybrid View

  1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    18
    Vote Rating
    0
    deepakse is on a distinguished road

      0  

    Default Answered: How to solve "Uncaught SyntaxError: Unexpected token < " Error.

    Answered: How to solve "Uncaught SyntaxError: Unexpected token < " Error.


    Hi,
    i have created a simple form using sencha touch and i use MySQL as a back-end for storing data.My basic functionality is just user fill the form and values of textfield in the form is stored in to MySQL table.Every beginer try to do it.But i am facing problem with storing data into table.
    here is my code.

    Ext.define('SenchaDemo.view.Main',
    {
    extend: 'Ext.Panel',
    xtype: 'mainpage',
    requires: [
    'Ext.TitleBar',
    'Ext.Video'
    ],
    config:
    {
    fullscreen:true,
    items:[
    {
    xtype:'textfield',
    id:'tname',
    name:'name',
    label:'Name'
    },
    {
    xtype:'textfield',
    id:'temail',
    name:'email',
    label:'Email'
    },
    {
    xtype:'textfield',
    id:'tmsg',
    name:'message',
    label:'Message'
    },
    {
    xtype:'button',
    name:'submit',
    text:'click here',
    id:'b1',
    listeners:{
    tap:function()
    {

    // fetch value from text field

    var fname=Ext.getCmp('tname').getValue();
    var femail=Ext.getCmp('temail').getValue();
    var fmsg=Ext.getCmp('tmsg').getValue();
    //console.log(fname,femail,fmsg);

    mystore.setProxy({
    type:'jsonp',
    url:'http://10.16.10.244/senchaDB/userinsert.php',
    method: "POST",
    //callbackKey: 'callback',
    /*reader:{
    type:'json'
    },*/
    /*success:function(result,request)
    {
    var text = result.responseText;
    //Ext.Msg.alert(text);
    console.log(text);
    },*/
    extraParams:
    {
    pname:fname,
    pemail:femail,
    pmsg:fmsg
    }


    });

    mystore.load();
    Ext.Msg.alert("Data Successfully store on the server");


    }
    }

    }
    ]




    }
    });
    and server side code id here
    <?php$con=mysql_connect("localhost","root","");
    $db=mysql_select_db("triumphsys",$con);
    //$callback=$_REQUEST['pname'];
    //$name=$_GET['pname'];
    //$email=$_GET['pemail'];
    //$msg=$_GET['pmsg'];
    //echo"".$years;
    $query="INSERT INTO userinfo(name,email,msg)VALUES('".$_POST['pname']."','".$_POST['pemail']."','".$_POST['pmsg']."')";
    //"insert into userinfo(name,email,msg)values('$_POST['pname']','$_POST['pemail']','$_POST['pmsg']')"
    $result=mysql_query($query);
    mysql_close($con);
    ?>
    Error Code here

    [COLOR=red !important]Uncaught SyntaxError: Unexpected token < userinsert.php:1


    [/COLOR]


    Please suggest me where i did wrong code.

  2. What does the response look like? Also, why aren't you just using a form panel and submitting the form? Why are you loading a store to submit data?

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Answers
    3540
    Vote Rating
    851
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    What does the response look like? Also, why aren't you just using a form panel and submitting the form? Why are you loading a store to submit data?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread