Tag: php

使用Ajax上传图像但PHP没有看到文件

因此,当我以标准方式使用表单时,PHP工作正常。 但是,当我尝试通过ajax发送表单时,它没有看到$ _file []并返回,“success | na”如果没有文件我想要它做,但是如果有的话我会得到相同的结果一份文件。 ajax设置是否正确? cashe:false,processData:false? 任何帮助都会有帮助,我总是可以使用iframe,但我宁愿不这样做。 谢谢你的时间! function info_save(){ gf.wait(); var info_ava = ”; var info_abo = $(‘#info_abo’).val() target = ‘./php/profile_system.php’; $.ajax({ url: “./php/profile_image.php”, type: “POST”, data: new FormData(‘#info_for’), contentType: false, cache: false, processData:false, success: function(reply){ imgresponse = reply.split(“|”); if(imgresponse[0] == ‘success’ || imgresponse[0] == ‘Success’){ if(imgresponse[1] == ‘na’){info_ava = ‘ ‘;} […]

从JavaScript传递并获取ID到PHP控制器

我有一个内联可编辑表(我使用了Tabledit ),每行都有一个ID,ID应传递给控制器​​操作(Yii2),以便我将编辑后的数据保存到数据库中。 这是我的js文件中的Tabledit代码: file.assetID = info.response; // the ID for (var i = 0; i < file.length; i++) { // the table if (file[i].type == "image/jpeg") { var type = "photo"; } else if (file[i].type == "video/mp4") { var type = "video"; } messageHtml += '’; messageHtml += ” + file[i].assetID + ”; messageHtml += […]

Featherlight隐藏div关闭

我正在尝试创建一个提交数据的预览屏幕,并将其显示在Featherlight Lightbox中。 我有以下示例代码。 jQuery(document).ready(function() { //Triggle when Preview Button is Clicked. jQuery(‘.OpenLightBox’).off(‘click’).on(‘click’, function( e ) { var pa_firstname= jQuery(‘input[name=”pa-[name_first]”]’).val(); var pa_lastname= jQuery(‘input[name=”pa-[name_last]”]’).val(); if (pa_firstname == null || pa_firstname == ”) { alert(‘Cannot be empty’); return false; } else { jQuery(‘.LightBox’).empty(); jQuery(‘.LightBox’).append(‘First Name in Ajax is’ + pa_firstname + ‘ And Last Name in Ajax is […]

jQuery Knob Release函数附加参数

我正在使用jQuery Knob插件https://github.com/aterrien/jQuery-Knob 现在,我有以下jQuery旋钮初始化 loop <input type="text" value="” class=”circle-rating” data-entryid=””> endloop $(function() { $(“.circle-rating”).knob({ ‘min’:0, ‘max’:10, ‘step’:1, ‘width’:40, ‘height’:40, ‘fgColor’:”#F59B00″, ‘inputColor’:”#F59B00″, ‘displayPrevious’: true, ‘release’ : function (v) { var entry_id = $(this).attr(‘data-entryid’); jQuery.post(“/path/to/file/update_library_score.php”, {v : v, entry_id : entry_id}, function(data) { console.log(entry_id); jQuery(‘#notification-general’).html(entry_id); }); } }); }); 主要问题是我在页面上有多个旋钮。 这些旋钮实际上是一个带有wordpresspost的循环。 无论如何,每个旋钮都附加到一个ID ,当你通过循环时,这个ID发生变化。 现在为了能够更新分数,我需要两个东西,即从release函数获得的旋钮value ,我还需要post_id ,我只能在循环内获得。 那么如何才能将post_id变量赋予此函数? 通常我只需添加一个button或带有onclick=”my_function()但是,我不能用这个来做。抓住与你对应的$ […]

datatables +连接到db +获取数据,但某些function无法正常工作

我是数据表的新手,喜欢它,想了解更多。 我目前的问题是与数据库通信。 我可以获得所有数据,但有些function不会被破坏(例如分页,每页的条目,搜索,每列的搜索)。 这是我的小提琴 ,相当基本。 我已经在tbody标签中加入了2行,用于测试搜索和列搜索的数据。 我的困难是让它与数据库数据一起工作。 所以在我连接到db的示例中,它与上面的小提琴略有不同。 它有一个index3.php文件,它指向employee-grid-data3.php文件 在我的index.php中的Code下面,指向employee-grid-data3.php以连接到db $(document).ready(function() { var dataTable = $(‘#employee-grid’).DataTable( { “processing”: true, “serverSide”: true, “ajax”:{ url :”employee-grid-data3.php”, // json datasource type: “post”, // method , by default get error: function(){ // error handling $(“.employee-grid-error”).html(“”); $(“#employee-grid”).append(‘No data found in the server — startagain1-index3.php ‘); $(“#employee-grid_processing”).css(“display”,”none”); } } } ); […]

如何使用jQuery或JavaScript基于当前URL和单击事件将一个类“active”分配给li元素

我正在尝试创建一个菜单,只要选择并加载了一个类“active”就会被分配给该页面。 现在它默认仅应用于索引页面。 我的菜单片段: Main News Contacts

如何将php变量传递给jquery

我尝试将php变量传递给jquery,我已经尝试使用了 但是当我尝试使用时,它并没有取得成功 dataSource:insted dataSource: [ { childName: “Child1”, childId: 1, parentId: 1 }, { childName: “Child2”, childId: 2, parentId: 2 }, { childName: “Child3”, childId: 3, parentId: 1 }, { childName: “Child4”, childId: 4, parentId: 2 } ] 它不能显示第二个选择,但我发现$ data与原始数据相同 我的代码, Kendo UI Snippet $(“#parent”).kendoDropDownList({ dataTextField: “parentName”, dataValueField: “parentId”, dataSource: [ { parentName: “Parent1”, parentId: […]

jquery从php中的选定行中获取内容

这是源代码,当我检查checbox而不是从表中获取所有内容时,它无法获取所选内容…任何人都可以发现我的代码中有什么错误…感谢你的时间 for(k=0;k<=9000;k++) { //each change $("#status"+k).click(function() { for(j=0;j<=numOflimit;j++) { var product_name = encodeURIComponent($('#product_name'+j).val()); alert(product_name); var barcode = encodeURIComponent($('#barcode'+j).val()); var Quantity = encodeURIComponent($('#Quantity'+j).val()); var cart=product_name + barcode + Quantity; alert(cart); $('#cart1').val(cart); } }); });

使用Ajax将图像发送到数据库(php)而无需重新加载

我创建了一个bootstrap模式弹出窗体,在图库页面中添加图片,我开发了php和ajax代码,因为我想在这里没有页面重新加载: – 问题是,当我想将图像发送到数据库时,我显示此错误 Notice: Undefined index: photo in …. 我无法发送图片。 这是我的ajax代码 $(function() { //twitter bootstrap script $(“button#submit”).click(function(){ $.ajax({ type: “POST”, url: “image.php”, data: $(‘form.contact’).serialize(), success: function(msg){ $(“#thanks”).html(msg) $(“#myModal”).modal(‘hide’); }, error: function(){ alert(“failure”); } }); }); }); 这是Image.php文件 include ‘db.php’; if(isset($_POST[‘titre’])){ $titre = strip_tags($_POST[‘titre’]); $image_name = $_FILES[‘photo’][‘name’]; $image_tmp = $_FILES[‘photo’][‘tmp_name’]; $image_size = $_FILES[‘photo’][‘size’]; $image_ext = pathinfo($image_name, […]

AJAX调用wordpress模板

我的工作php / javascript / ajax应用程序进入我的wordpress主题时遇到了问题。 我将它用于我的用户,而不是在管理面板中。 我已经做了什么:我在我的functions.php中调用了JavaScript文件。 它的装载很好。 但是,当我打开我的主要php文件时,它不会进行ajax调用。 我有4页:response.php response.php(这个工作正常。) single-page.php(这个也工作正常。) voedingsschema.js(这个没有wordpress工作。) function.php(我不知道我是否做得对。) 我希望我已经提供了足够的信息。 我的模板中的function.php代码如下所示: function fitnesszone_child_scripts(){ wp_enqueue_script( ‘voedingsschema js’, get_stylesheet_directory_uri() . ‘/js/voedingsschema.js’); } add_action( ‘wp_enqueue_scripts’, ‘fitnesszone_child_scripts’); javascript代码: $(document).ready(function() { //##### send add record Ajax request to response.php ######### $(“#FormSubmit”).click(function (e) { e.preventDefault(); if($(“#contentText”).val()===”) { alert(“Please enter some text!”); return false; } $(“#FormSubmit”).hide(); //hide […]