Nasıl .. Bu işlev boş dönmek olduğunu biliyorum ve ben bunu nasıl gösterebilirim?

3 Cevap php

Hi I am not familiar with javascripts...so cant understand how do I check which variable return empty?? if tweet is there then it fill with tweets but if not then it wont show up. but I want know which varible is fills the container and if I want show "there is no tweets for you" then where will I add that??

$(document).ready(function() {
    $.twtter.start({
        searchType:"searchWord", 
        searchObject:"google", 
        lang:"en", 
        live:"live-180", 
        placeHolder:"twitterdiv", 
        loadMSG: "Loading messages...", 
        imgName: "loader.gif", 
        total: 6, 
        readMore: "Read it on Twitter", 
        nameUser:"image", 
        openExternalLinks:"newWindow", 

    });
    $("#twitSearch").submit(function(){

        $.twtter.start({

            searchType:"searchWord",

            searchObject:$(".twitSearch").val(),
            live:"live-180", 

        });
                return false;

    });


})

sonuç görüntülenir

<div id="twitterdiv"></div>

THanks

3 Cevap

Hayır, JavaScript PHP sunucu tarafı istemci tarafı. Ikisi arasında büyük bir kavramsal uçurum vardır.

Server Side Vs. Client Side

Devam Warning Aptal cevap

JavaScript

window.location = 'script.php?test=' + myVar;

PHP

echo (empty($_GET['test'])) ? 'empty' : 'not empty';

Bu uyarı çanları edilmelidir.

Sen en azından (ya da diğerleri) demek yapmaz bir şekilde, bir JavaScript değişken boş olup olmadığını kontrol etmek için PHP kullanamazsınız WTF.

Ne muhtemelen istediğiniz bunu yapmak için farklı bir yoldur. Eğer bir PHP komut dosyası için tüm JavaScript değişkenleri göndermek ve daha sonra PHP bunları doğrulamak. Fazla kod gönderin.

Sadece JavaScript içinde bunu yapmak istiyorum (bir dize ise) Yoksa, bu gibi yapabilirsiniz

if (myVar === '') {
   alert('empty');
}

Bunun yerine PHP dili yapı gibi bir empty işlevi olurdu ya da eğer, ile gitmek

function empty(str) {
    return (str === '');
}

You can not check whether or not a javascript variable is empty with php. Kodunuzu sonrası olabilir, biz daha iyi soruna alabilir.