-1
我有以下代碼需要使用ajax請求提交。這是形式Ajax請求未提交PHP執行形式
<form action="genformexec.php" id="genform" method="post" enctype="multipart/form-data">
<label class="type" for="ccode">*Your confirmation code is the series of numbers sent to your mail after payment verification</label>
<input class="half" type="text" name="ccode" id="ccode" placeholder="Confirmation Code">
<input class="half" type="email" name="uemail" id="uemail" placeholder="Email Address">
<input class="half" type="text" name="fname" id="fname" placeholder="First Name">
<input class="half" type="text" name="lname" id="lname" placeholder="Last Name">
<input class="full" type="text" name="cname" id="cname" placeholder="Company Name">
<input class="full" type="text" name="crcnum" id="crcnum" placeholder="Company RC/BN Number">
<input class="full" type="text" name="uaddress" id="uaddress" placeholder="Residential Address">
<input class="full" type="text" name="caddress" id="caddress" placeholder="Company Address">
<textarea class="full" rows="7" name="briefdes" id="briefdes" placeholder="Brief description about your company"></textarea>
<input class="half" type="text" name="uname" id="uname" placeholder="Username">
<input class="half" type="text" name="uphone" id="uphone" placeholder="Phone Number">
<input class="half" type="text" name="pword" id="pword" placeholder="Password">
<input class="half" type="text" name="cfpword" id="cfpword" placeholder="Re-Type Password">
<div class="profImage"><img id="logo_prev" src=""></div><br>
<label for="profimages">Upload Company Logo/Profile Picture</label><br><br>
<input type="file" onchange="logo_prev()" name="profimages" id="profimages">
<label class="type">Select Your Sectoral Group(s)</label>
<div class="postLimit">
<p class="limitType">Motor Vehicle and Miscellaneous Assembly</p>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Boat/Ship Building">Boat/Ship Building</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Automobile Components">Automobile Components</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Electrical Generators Assemblers">Electrical Generators Assemblers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Miscellaneous Machine and Equipment">Miscellaneous Machine and Equipment</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Bicycle">Bicycle</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Motorcycle Assemblers">Motorcycle Assemblers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Horological">Horological</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Motor Vehicle Assemblers">Motor Vehicle Assemblers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Boat/Ship Building, Automobile Components, Electrical Generators Assemblers, Miscellaneous Machine and Equipment, Bicycle, Motorcycle Assemblers, Horological, Motor Vehicle Assemblers">All</div>
</div>
<div class="postLimit">
<p class="limitType">Chemical and Pharmaceuticals</p>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Paints, Vanishes and Allied Products">Paints, Vanishes and Allied Products</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Industrial, Medical and Special Gases">Industrial, Medical and Special Gases</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Soap and Detergent">Soap and Detergent</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Agro-Chemicals (Fertilizers and Pesticides)">Agro-Chemicals (Fertilizers and Pesticides)</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Pharmaceuticals">Pharmaceuticals</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Safety Matches">Safety Matches</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Dry Cell Battery">Dry Cell Battery</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Gramophone Records and Musical Tapes Manufacturers">Gramophone Records and Musical Tapes Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Petroleum Products">Petroleum Products</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Candle Manufactures">Candle Manufactures</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Printing Ink Manufactures">Printing Ink Manufactures</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Toiletries and Cosmetics">Toiletries and Cosmetics</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Basic Industrial Chemicals">Basic Industrial Chemicals</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Automotive Battery">Automotive Battery</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Resin Manufacturers">Resin Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Ball Point Pen Manufacturers">Ball Point Pen Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Paints, Vanishes and Allied Products, Industrial, Medical and Special Gases, Soap and Detergent, Agro-Chemicals (Fertilizers and Pesticides), Pharmaceuticals, Safety Matches, Dry Cell Battery, Gramophone Records and Musical Tapes Manufacturers, Gramophone Records and Musical Tapes Manufacturers, Petroleum Products, Candle Manufactures, Printing Ink Manufactures, Toiletries and Cosmetics, Basic Industrial Chemicals, Automotive Battery, Resin Manufacturers, Ball Point Pen Manufacturers">All</div>
</div>
<div class="postLimit">
<p class="limitType">Non-Metallic Mineral Products</p>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Glass Manufacturers">Glass Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Ceramics Manufacturers">Ceramics Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Abestos Manufacturers">Abestos Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="School Chalks and Crayons">School Chalks and Crayons</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Cement Manufacturers">Cement Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Glass Manufacturers, Ceramics Manufacturers, Abestos Manufacturers, School Chalks and Crayons, Cement Manufacturers">All</div>
</div>
<div class="postLimit">
<p class="limitType">Wood and Wood Products Including Furniture</p>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Wood Products and Furniture (Excluding Metal Furniture)">Wood Products and Furniture (Excluding Metal Furniture)</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Plywood and Particle Board Manufacturers">Plywood and Particle Board Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Wood Products and Furniture (Excluding Metal Furniture), Plywood and Particle Board Manufacturers">All</div>
</div>
<div class="postLimit">
<p class="limitType">Basic Metal, Iron and Steel and Fabricated Metal Products</p>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Association of Steel Pipe Manufacturers">Association of Steel Pipe Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Metal Packaging Manufacturers">Metal Packaging Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Foundry">Foundry</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Metal Manufacturers and Fabricators">Metal Manufacturers and Fabricators</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Association of Primary Aluminium Producers">Association of Primary Aluminium Producers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Enamel Wares Manufacturers">Enamel Wares Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Welding Electrode Manufacturers">Welding Electrode Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Galvanised Iron Sheets Mnaufacturers">Galvanised Iron Sheets Mnaufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Nail and Wire Manufacturers Group">Nail and Wire Manufacturers Group</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Association of Steel Pipe Manufacturers, Metal Packaging Manufacturers, Foundry, Association of Primary Aluminium Producers, Enamel Wares Manufacturers, Welding Electrode Manufacturers, Metal Manufacturers and Fabricators, Galvanised Iron Sheets Mnaufacturers, Nail and Wire Manufacturers Group">All</div>
</div>
<div class="postLimit">
<p class="limitType">Food, Beverages and Tobacco</p>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Beer">Beer</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Starch and other Miscellaneous Food Products">Starch and other Miscellaneous Food Products</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Flavouring">Flavouring</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Soft Drinks and Carbonated Water">Soft Drinks and Carbonated Water</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Flour and Grain Milling">Flour and Grain Milling</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Meat and Fish">Meat and Fish</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Tea, Coffee and other Beverages">Tea, Coffee and other Beverages</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Dairy Products">Dairy Products</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Tobacco">Tobacco</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Biscuits and Bakery Products">Biscuits and Bakery Products</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Sugar">Sugar</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Distillery and Blending of Spirit">Distillery and Blending of Spirit</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Cocoa, Chocolate and Sugar Confectionery">Cocoa, Chocolate and Sugar Confectionery</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Vegetable and Edible Oil">Vegetable and Edible Oil</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Poultry Group">Poultry Group</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Beer, Starch and other Miscellaneous Food Products, Flavouring, Soft Drinks and Carbonated Water, Flour and Grain Milling, Meat and Fish, Tea, Coffee and other Beverages, Dairy Products, Tobacco, Biscuits and Bakery Products, Distillery and Blending of Spirit, Cocoa, Chocolate and Sugar Confectionery, Vegetable and Edible Oil, Poultry Group">All</div>
</div>
<div class="postLimit">
<p class="limitType">Textile, Wearing Appareal, Carpet, Leather/Leather Footwear Sectoral Group</p>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Textile and Wearing Apparel Manufacturers">Textile and Wearing Apparel Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Leather Products Manufacturers">Leather Products Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Carpet and Rug Manufacturers">Carpet and Rug Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Footwear Manufacturers">Footwear Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Flour and Grain Milling">Flour and Grain Milling</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Cordage, Rope and Twine Manufacturers">Cordage, Rope and Twine Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Textile and Wearing Apparel Manufacturers, Leather Products Manufacturers, Carpet and Rug Manufacturers, Footwear Manufacturers, Flour and Grain Milling, Cordage, Rope and Twine Manufacturers">All</div>
</div>
<div class="postLimit">
<p class="limitType">Electrical and Electronics Sectoral Group</p>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Electronics">Electronics</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Refrigerators and Airconditioning/Domestic Appliances">Refrigerators and Airconditioning/Domestic Appliances</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Electric Bulb Lamps, Accessories and Fittings">Electric Bulb Lamps, Accessories and Fittings</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Cable and Wire">Cable and Wire</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Electrical Power Control and Distribution Equipment">Electrical Power Control and Distribution Equipment</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Electronics, Refrigerators and Airconditioning/Domestic Appliances, Electric Bulb Lamps, Accessories and Fittings, Cable and Wire, Electrical Power Control and Distribution Equipment">All</div>
</div>
<div class="postLimit">
<p class="limitType">Pulp, Paper and Paper Products, Printing and Publishing Sectoral Group</p>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Chemical and Stationery Manufacturers">Chemical and Stationery Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Printing, Publishing and Packaging">Printing, Publishing and Packaging</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Pulp, Paper and Paper Products">Pulp, Paper and Paper Products</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Sanitary Towels, Napkins and Diapers">Sanitary Towels, Napkins and Diapers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Chemical and Stationery Manufacturers, Printing, Publishing and Packaging, Pulp, Paper and Paper Products, Sanitary Towels, Napkins and Diapers">All</div>
</div>
<div class="postLimit">
<p class="limitType">Domestic And Industrial Plastic, Rubber And Foam Sectoral Group</p>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Rubber Products">Rubber Products</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Domestic and Industrial Plastics">Domestic and Industrial Plastics</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Foam Manufacturers">Foam Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Bags and Suitcases Manufacturers">Bags and Suitcases Manufacturers</div>
<div class="checkin"><input type="checkbox" name="postValue[]" value="Rubber Products, Printing, Domestic and Industrial Plastics, Foam Manufacturers, Bags and Suitcases Manufacturers">All</div>
</div><br><br><br><br><br><br><br>
<label class="type" for="regas">You are registering as:</label>
<input type="text" class="full readonly" readonly name="regas" id="regas" value="Manufacturer">
<label class="type" for="package">Package type:</label>
<input type="text" class="full readonly" readonly name="package" id="package" value="Gold">
<input type="submit" name="regSubmit" id="regSubmit" value="Submit">
</form>
這是我的Ajax請求
$("#genform").submit(function(e) {
e.preventDefault();
$.ajax({
type: "POST", //or "GET", if you want that
url: "genformexec.php",
data: $(this).serializeArray(),
dataType: "json",
success: function(response) {
$('.responsealert').html(response);
},
error: function(response) {
//function called if request failed
}
});
});
但問題是,當我提交表單,它不會提交給數據庫沒有響應,但是當我檢查我的開發人員工具的xhr狀態是200這是好的。請問有什麼可能是錯的?
你得到的迴應是什麼?爲什麼你有一個空的'error'塊?你不應該這樣做.. idk ..顯示一個錯誤? – GrumpyCrouton
[jQuery AJAX提交表單]的可能重複(https://stackoverflow.com/questions/1960240/jquery-ajax-submit-form) –
@diagold,太糟糕了,它不可能請求'ajax'包括'file' 。你可以使用'iframe'。 –