English 中文(简体)
jquery Mobile and json callsback results not show
原标题:jquery mobile and json callback result not displayed

我正在建造一个支离破碎的移动设备,使用户能够通过json张贴和观看专题。 服务器的一方使用php和我的q子注射来收集json数据。 服务器方面确实看到了过去的价值,并成功地将其注入了q。 问题在于它没有取得成功的退步结果。

这一错误记录显示 Chrome鱼的特性:XMLHttpRequest不能装载 http://xxxxx/newpost.php。 查阅-Control-Allow-Origin>/code 不允许原产地无效,如果在参数中添加的“jsonp”号” 不详 Error: SUCCESS is not defined

这里是我的html:

<div data-role="content">
            <div data-role="content">
                <form id="newPostForm">
                    <div data-role="fieldcontain">
                        <label for="postTitle"><strong>Post Title:</strong></label>
                        <input type="text" name="postTitle" id="postTitle" value=""  />

                        <label for="postContent"><strong>Post Content:</strong></label>
                        <textarea name="postContent" id="postContent"></textarea>

                        <fieldset class="ui-grid-a">
                            <div class="ui-block-a"><a href="#indexPage" id="cancel" data-role="button">Cancel</a></div>
                            <div class="ui-block-b"><button data-theme="b" id="submit" type="submit">Submit</button></div>
                        </fieldset>
                        <h3 id="notification"></h3>
                    </div>
                </form>
            </div>
        </div>

说明:

function resetTextFields()
        {
            $("#postTitle").val("");
            $("#postContent").val("");
        }

        function onSuccess(data, status)
        {
            resetTextFields();
            // Notify the user the new post was saved
            $("#notification").fadeIn(2000);
            data = $.trim(data);
            if(data == "SUCCESS")
            {
                $("#notification").css("background-color", "#ffff00");
                $("#notification").text("The post was saved");
            }
            else
            {
                $("#notification").css("background-color", "#ff0000");
                $("#notification").text(data);
            }
            $("#notification").fadeOut(5000);
        }

        $(document).ready(function() {
            $("#submit").click(function(){

                var formData = $("#newPostForm").serialize();

                $.ajax({
                    type: "POST",
                    url: "http://xxxxxxxx/newpost.php",
                    cache: false,
                    data: formData,
                    success: onSuccess
                });

                return false;
            });

            $("#cancel").click(function(){
                resetTextFields();
            });

            $("#refresh").click(function(){
                location.reload();
            });
        });

and here s the php code:

header( Content-type: application/json );
    try
    {
        $connection = mysql_connect("localhost","user","pass");
        mysql_select_db("dbtable", $connection);

        $postTitle = mysql_real_escape_string($_POST[postTitle]);
        $postContent = mysql_real_escape_string($_POST[postContent]);

        mysql_query("INSERT INTO weblogins (postTitle, postContent) VALUES ( $postTitle ,  $postContent )");
        mysql_close($connection);
        echo "SUCCESS";
    }
    catch(Exception $e)
    {
        echo $e->getMessage();
    }

当 but子受到压力时,客户一方没有发生任何事情,没有通知,而是将所提交的表格注入了.。

我错了什么? 感谢。

问题回答

你们不能把非洲宇宙航空研究开发机构引向一个不是目前的领域。

http://en.wikipedia.org/wiki/Same_origin_policy”rel=“nofollow”http://en.wikipedia.org/wiki/Same_origin_policy

页: 1

dataType: "jsonp",

页: 1





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签