inserting data to table in php using ajax

i am adding data and upload files in php using ajax but it return require appname i will write query in GetPhp.php appname is required

if(!appid)
    {
    var appname=document.getElementById("appname").value;
    parameters ="appname="+appname;
    /*var apptype=document.getElementById("apptype").value;
    parameters ="apptype="+apptype;
    var appurl=document.getElementById("appurl").value;
    parameters ="appurl="+appurl;
    var appguid=document.getElementById("appguid").value;
    parameters ="appguid="+appguid;
    var cname=document.getElementById("cname").value;
    parameters ="cname="+cname;*/
    $.ajaxFileUpload
            (
            {

                    url:'uploadplist.php',
                    secureuri:false,
                    fileElementId:'plist',
                    dataType: 'json',
                    data:{name:'logan', id:'id'},
                    success: function (data, status)
                    {


                        var plist=data.msg;

                        parameters +="&plist="+plist;

                       $.ajaxFileUpload
                         (
                          {

                          url:'uploadipa.php',
                          secureuri:false,
                          fileElementId:'ipa',
                          dataType: 'json',
                          data:{name:'logan1', id:'id1'},
                          success: function (data, status)
                          {
                           var ipa=data.msg;
                           parameters +="&ipa="+ipa;
                              $.ajaxFileUpload
                             (
                              {

                            url:'uploadprovision.php',
                            secureuri:false,
                            fileElementId:'provision',
                            dataType: 'json',
                            data:{name:'logan2', id:'id2'},
                            success: function (data, status)
                            {
                            var provision=data.msg;
                            parameters +="&provision="+provision;
                            $("input#appname").val('');
                            /*$("input#apptype").val('');
                            $("input#appurl").val('');
                            $("input#appguid").val('');
                            $("input#cname").val('');*/
                            $('#mask').hide();
                            $('.window').hide();
                            httprequest.onreadystatechange=alertContents;
                            httprequest.open('POST','GetPhp.php',true);
                            httprequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                            httprequest.setRequestHeader("Content-length", parameters.length);
                            httprequest.setRequestHeader("Connection", "close");
                            httprequest.send(parameters);
                            },
                           error: function (data, status, e)
                           {
                           alert(e);
                           }
                         }
                       )

                          },
                         error: function (data, status, e)
                         {
                         alert(e);
                         }
                         }
                       )


                    },
                    error: function (data, status, e)
                    {
                        alert(e);
                    }
            }
            )

            }

i insert only appname its working when i am removing the comments for apptype ,appurl,appquid,cname its not uploaded quid me

Answers


I'm not entirely clear on what you're asking but I think your problem is here:

var appname=document.getElementById("appname").value;
parameters ="appname="+appname;
var apptype=document.getElementById("apptype").value;
parameters ="apptype="+apptype;
var appurl=document.getElementById("appurl").value;
parameters ="appurl="+appurl;
var appguid=document.getElementById("appguid").value;
parameters ="appguid="+appguid;
var cname=document.getElementById("cname").value;
parameters ="cname="+cname;

You're replacing parameters not adding to it. Try...

var appname=document.getElementById("appname").value;
parameters ="appname="+appname;
var apptype=document.getElementById("apptype").value;
parameters +="&apptype="+apptype;
...

(notice the += and the additional &)

or more readably...

var parameters =
    "appname="  + $("#appname").val() + 
    "&apptype=" + $("#apptype").val() +
    "&appurl="  + $("#appurl").val() +
    "&appguid=" + $("#appguid").val() + 
    "&cname="   + $("#cname").val();

You may also need to urlencode the parameters (it's good practice)

eg ...

var parameters =
    "appname="  + encodeURIComponent($("#appname").val()) + 
    "&apptype=" + encodeURIComponent($("#apptype").val()) +
    "&appurl="  + encodeURIComponent($("#appurl").val())  +
    "&appguid=" + encodeURIComponent($("#appguid").val()) + 
    "&cname="   + encodeURIComponent($("#cname").val());

Need Your Help

SharePoint 2013 web part button click event not firing

c# asp.net sharepoint sharepoint-2013 web-parts

I am building my first Hello World Web part using the Cloud 9 videos as tutorial.

Call parent function inside included/required file

php class include require

I would like to know if it is possible to call a function of a parent file inside a included file and how that could be work.