twitter-bootstrap x-editable ajax调用不处理指定的url

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16802006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 17:14:46  来源:igfitidea点击:

x-editable ajax call does not process the designated url

ajaxjquerytwitter-bootstrapx-editable

提问by TimM

Im using bootstrap with x-editable and im trying to get it working once the save button from x-editable is clicked the php file should be executed.

我将引导程序与 x-editable 一起使用,并且一旦单击 x-editable 中的保存按钮,我就会尝试让它工作,应该执行 php 文件。

Ive tried everything within my knowledge to fix this but im not a hardcore javascript programmer so changing it to Json to give it a try is to my perspective a little much effort.

我已经尝试了我所知道的一切来解决这个问题,但我不是一个铁杆 javascript 程序员,所以将其更改为 Json 以尝试一下对我的观点来说需要付出很多努力。

Ive read the documentation of x-editable and this should be the way to work with it.

我已经阅读了 x-editable 的文档,这应该是使用它的方法。

So here is the html:

所以这是html:

  <a href="#" class="username">superuser</a> 

The Javascript:

Javascript:

      $.fn.editable.defaults.mode = 'inline';

      $('.username').editable({
           type: 'text',
           pk: 1,
           url: 'post.php',
         });

Once the post.phpis missing x-editable gives an error , however if it sees the php file it does nothing. the contents from the php file are irrelevant because there is only a console log with test in it there.

一旦post.php丢失 x-editable 给出一个错误,但是如果它看到 php 文件它什么都不做。php 文件中的内容无关紧要,因为那里只有一个带有测试的控制台日志。

The console log is never executed and i cant figure out why it is not working, I've seen 1 or 2 problems like thing one on Stackoverflow etc however no use full information.

控制台日志从未执行过,我无法弄清楚为什么它不起作用,我已经看到 1 或 2 个问题,例如 Stackoverflow 上的一个问题,但是没有使用完整信息。

This is the first time ever i had to ask something on the internet so i hope someone can help me with this one.

这是我第一次不得不在互联网上提问,所以我希望有人能帮助我解决这个问题。

I've tried things like changing the urlto localhost/dir/etchowever no effect. also setting /posturl, and adding var posturl = "post.php";didn't help

我已经尝试过将 更改为 之类的事情urllocalhost/dir/etc但没有效果。还设置/posturl,并添加 varposturl = "post.php";没有帮助

oh and I've tested all the resources : but if it helps here:

哦,我已经测试了所有资源:但如果它在这里有帮助:

<!-- Le styles -->  
<!-- jQUERY -->
<script src="http://code.jquery.com/jquery.js"></script>
<!-- Sharre -->
<script src="recources/assets/js/jquery.sharrre-1.3.4.js"></script>
<!-- Minnified bootstrap -->
<script src="recources/assets/min/js/bootstrap.min.js"></script>
<!-- Custom CSS -->
<link href="recources/assets/css/pagestyle.css" rel="stylesheet">
<!-- X - Editable -->
<link href="recources/assets/css/bootstrap-editable.css" rel="stylesheet">
<!-- External link -->
<script src="//cdnjs.cloudflare.com/ajax/libs/x-editable/1.4.4/bootstrap-editable/js/bootstrap-editable.min.js"></script>

回答by Amirhossein Mehrvarzi

Use sendparameter as it can determine Strategyfor sending data to server. It Can be auto| always| never. When 'auto' data will be sent on server only if pkand urldefined, otherwise new value will be stored locally.

使用send参数,因为它可以确定将数据发送到服务器的策略。它可以是自动的| 总是| 从来没有。当 'auto' 数据仅在pkurl定义时才会在服务器上发送,否则新值将存储在本地

You can set it for all inputs by this code:

您可以通过以下代码为所有输入设置它:

$.fn.editable.defaults.send = "always";

Or Customize each input for related strategy like this:

或为相关策略自定义每个输入,如下所示:

$('.username').editable({
    send: 'always'
});

回答by Brice Durand

Have you tried modifying the send option ?

您是否尝试过修改发送选项?

$('.username').editable({
    type: 'text',
    pk: 1,
    url: 'post.php',
    send: 'always'
});

Otherwise try debugging the unminified version bootstrap-editable.js and add a breakpoint here https://github.com/vitalets/x-editable/blob/master/src/editable-form/editable-form.js#L189. I had a similar issue and that's what I did. Hope that helps.

否则尝试调试未缩小的版本 bootstrap-editable.js 并在此处添加断点https://github.com/vitalets/x-editable/blob/master/src/editable-form/editable-form.js#L189。我有一个类似的问题,这就是我所做的。希望有帮助。