Tag: php

Jquery :: Ajax动力进度条?

我有一个页面,它使用jquery的ajax函数来发送一些消息。 可能会发送超过50k的消息。 这显然需要一些时间。 我要做的是显示一个进度条,其中包含正在发送的消息。 后端是PHP。 我怎样才能做到这一点? 我的解决方案:通过原始ajax调用中的唯一标识符发送。 此标识符存储在数据库(或使用标识符等命名的文件)中,以及完成百分比。 这会在原始脚本继续时更新。 一个名为progress(ident)的函数被设置 该函数对读取百分比的脚本进行ajax调用。 进度条更新如果返回的百分比不是100, 该函数设置超时,在1秒后调用自身。

尝试使用AJAX将变量值从JavaScript传递给PHP

我想使用jQuery / AJAX将一些值从JavaScript传递给PHP。 我有以下“简化”代码,不知道我做错了什么。 StackOverflow中似乎有很多类似的问题/答案,但它们都没有真正帮助。 HTML: Send text JAVASCRIPT: $(“#text-id”).click(function() { $.ajax({ type: ‘post’, url: ‘text.php’, data: {source1: “some text”, source2: “some text 2”} }); }); PHP(text.php): 问题:什么都没发生……没有错误……没什么。 我没有看到’echo1’和’source2’的值出现在PHP echo语句中。

如何从Laravel 5中的ajax调用返回视图

我正在尝试获取一个html表来返回ajax调用。 路线: Route::post(‘job/userjobs’, ‘JobController@userjobs’); 调用页面上的ajax: function getUserJobs(userid) { $_token = “{{ csrf_token() }}”; var userid = userid; $.ajax({ headers: { ‘X-CSRF-Token’ : $(‘meta[name=_token]’).attr(‘content’) }, url: “{{ url(‘/job/userjobs’) }}”, type: ‘POST’, cache: false, data: { ‘userid’: userid, ‘_token’: $_token }, //see the $_token datatype: ‘html’, beforeSend: function() { //something before send }, success: function(data) { console.log(‘success’); […]

laravel 5中的ajax post返回错误500(内部服务器错误)

这是我在laravel 5中的测试ajax(参见下文) $(“#try”).click(function(){ var url = $(this).attr(“data-link”); $.ajax({ url: “test”, type:”POST”, data: { testdata : ‘testdatacontent’ }, success:function(data){ alert(data); },error:function(){ alert(“error!!!!”); } }); //end of ajax }); 和触发链接 Try 和我的路线 Route::post(‘test’, function() { return ‘Success! ajax in laravel 5′; }); 但是当我在谷歌浏览器中运行控制台并且它没有返回预期的响应“返回’成功!在laravel 5中的ajax’时,它给了我错误;” POST http://juliver.laravel.com/test 500(内部服务器错误) 什么错误/我的代码有问题? 什么我失踪了?

什么是浏览器/手机检测的可用解决方案

我正在为各种移动平台创建一个phonegap应用程序,我想知道当前最好的浏览器/手机检测解决方案是什么? 我应该使用服务器或客户端检测,还是可以通过媒体类型屏幕宽度使用css解决方案?

Ajax LARAVEL 419 POST错误

我真的很感激这方面的一些帮助。 我在这个论坛上发布了大量的解决方案,但我无法让它发挥作用。 我的ajax电话是这样的 $(document).ready(function() { $(“#company”).click(function() { $.ajax({ type: “POST”, dataType:’html’, url : “/company”, success : function (data) { $(“#result”).html(data); } }); }); }); 我通过我的路线呼叫视图 Route::post(‘/company’, ‘Ajaxcontroller@loadContent’); 和控制器 public function loadContent() { return view(‘listing.company’)->render(); } 我的company.blade.php是 @foreach ($companies as $company) {{$company->name}} {{$company->streetaddress}} {{$company->postalcode}} is available on @endforeach 我收到了这个错误 POST http://127.0.0.1:8234/company 419 (unknown status)

Ajax上传不工作codeigniter

我正在使用codeigniter 3.1。 我想使用ajax发布上传数据。 Ajax上传文件不起作用。 但是当我发布没有ajax的简单表单时,它工作正常。 我不知道为什么但是在控制台中没有错误。 HTML ‘uploader’]) ?> JAVASCRIPT $(‘#uploader’).submit(function (event) { event.preventDefault(); $.ajax({ url: window.location.href + ‘/post’, type: “POST”, dataType: ‘json’, data: new FormData(this) }); }); CONTROLLERS public function post() { $this->load->helper(‘url’); $this->load->helper(‘form’); $this->load->library(“upload”); $file = $this->common->nohtml($this->input->post(“userfile”)); $this->upload->initialize(array( “upload_path” => ‘upload’, “overwrite” => FALSE, “max_filename” => 300, “encrypt_name” => TRUE )); $this->upload->do_upload(‘userfile’); $data […]

WordPress使用WordPress将ajax值传递给特定页面

我想将变量传递给特定页面。 我找到了一个简单的例子,解释了如何在wordpress中使用ajax。 JavaScript的: jQuery(document).ready(function($) { // We’ll pass this variable to the PHP function example_ajax_request var fruit = ‘Banana’; // This does the ajax request $.ajax({ url: ajaxurl, data: { ‘action’:’example_ajax_request’, ‘fruit’ : fruit }, success:function(data) { // This outputs the result of the ajax request console.log(data); }, error: function(errorThrown){ console.log(errorThrown); } }); }); 要在functions.php插入的PHP片段 […]

在CSS中包装长文本

我有文字喜欢 PellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesquePellentesque feugiat tempor elit. Ut mollis lacinia quam. Sed pharetra, augue aliquam ornare vestibulum, metus massalaoreet tellus, eget iaculis lacus ipsum et diam. 我不想要水平滚动。 是否可以包装文本(自动换行)。 我知道有一些IE特定的属性。 感谢您的时间。 更新:我也可以使用jQuery,Javascript,PHP来做到这一点。 但是怎么样? 我的意思是字母(字体)不是固定宽度或任何你称之为。

使用jquery post发布PHP文件

如果有人知道这段代码的问题,请告诉我。 基本上我想用jQuery上传文件 $(document).ready(function(event) { $(‘#form1’).submit(function(event) { event.preventDefault(); $.post(‘post.php’,function(data){ $(‘#result’).html(data); }); }); }); Please input the XML: call back result will appear here 和我的php’post.php’ 上传的文件名不会返回。 问题是我无法访问上传的文件。 提前致谢! 希夫