English 中文(简体)
发生错误: 辛塔克斯·埃多尔:
原标题:An error has occurred: SyntaxError: JSON.parse: unexpected character

我试图更新与JQuery/JSON的记录,但发现这一错误:

发生错误:

[目标]

副市长

辛塔克斯·埃多尔:

My JS:

jQuery( #commentForm ).live( submit , function (event) {
event.preventDefault()

    
jQuery.ajax(edit_url, {
    data: jQuery(this).serialize(),
    dataType:  json ,
    type:  POST ,
    success: function (data) {
        if (data.error ===  OK ) {
            alert( ok c good )
        } else {
            alert( hi  + data.error)
        }
    },
    error: function(x,y,z){
        alert( 发生错误:
  + x +  
  + y +  
  + z);
    }
})
    
return false;
})

www.un.org/spanish/ecosoc And my php:

$ret = array(
     error              =>   OK ,
);
$update =
    "UPDATE crm_set_users SET ".
        "crm_set_users_civilite =  ".mysql_real_escape_string($crm_set_users_civilite)." ,".
        "crm_set_users_nom =  ".mysql_real_escape_string($crm_set_users_nom)." ,".
        "crm_set_users_prenom =  ".mysql_real_escape_string($crm_set_users_prenom)." ,".
        "crm_set_users_email =  ".mysql_real_escape_string($crm_set_users_email)." , ".
        "crm_set_users_telephone =  ".mysql_real_escape_string($crm_set_users_telephone)." , ".
        "crm_set_users_portable =  ".mysql_real_escape_string($crm_set_users_portable)." ";
        
if($crm_set_users_photo != ""){
    $update .=", crm_set_users_photo =  ".mysql_real_escape_string($crm_set_users_photo)." ";
}   
    
$update .=
    "WHERE ".
        "crm_set_users_id =  ".mysql_real_escape_string($user_id)." ";




echo json_encode($ret);
exit;

如果我是:

$ret = array(
     error              =>   OK ,
);
echo json_encode($ret);
exit;

之后,它......

请你们帮助!

最佳回答

或许,你的PHP投下了一些错误或警告,使归还的文件不能成为有效的JSON。 参看以下表格:http://getfirebug.com/“rel=“nofollow”>FireBug,了解实际结果由您的PHP书写。

Following the PHP docu for mysql_real_escape_string (link)it will throw an Error, if there is no active MySQL connection available. Maybe that s your problem.

问题回答

问题必须是,更新记录的工作失败了,因此json没有产出。

I think you need to add a space before the WHERE

$update .=
    " WHERE ".

在护堤后给它一些房间





相关问题
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 ...

热门标签